简体   繁体   English

使字符串数组的所有字符串都变成小写,除了第一个单词

[英]Make all the strings of a string array into lower case except for the first word

Supposing I have an array Tomat, Ost How can I accomplish so it is like this: Tomat, ost ? 假设我有一个数组Tomat, Ost我该怎么做,就像这样: Tomat, ost

$ingredient_a = Array('Tomat', 'Ost');
echo implode(', ', $ingredient_a);

ucfirstarray_mapstrtolower array_map使用

echo ucfirst(implode(', ', array_map('strtolower',$ingredient_a)));
$ingredient_a = array('Tomat', 'Ost');
$new = array();

foreach($ingredient_a as $key => $value) {
    $key == 0 ? $new[] = $value : $new[] = strtolower($value);
}

echo implode(', ', $new);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在PHP中制作低位字母(字符串中的第一个字母除外)? - How to make lower letters in PHP, except the first one in a string? 大写字符串中的所有第一个字符(某些单词除外) - Upper Case all First Characters in a string Except certain words php 数组小写优先排序 - php array sort lower-case first 使用htaccess将网址转换为小写,查询字符串除外 - Convert url to lower case using htaccess except query string 在第一个空格上拆分字符串数组并按第一个单词进行新数组分组 - Split array of strings on first space and make new array grouping by first word 查找句子中数组中所有出现的字符串列表,并用短划线替换除第一个字母以外的所有内容 - Find all occurrences of list of strings in array inside a sentence, and replace everything except the first letter with dashes PHP - 字符串的所有组合大小写字符 - PHP - all combination upper and lower case characters of string 大写字符串中每个单词的第一个字符,除了'和','到'等 - Uppercase the first character of each word in a string except 'and', 'to', etc 替换 PHP 数组中包含单词的所有字符串 - replace all strings that contains a word in a PHP Array 将标题大小写应用于字符串中的所有单词,除了指定的首字母缩略词 - Apply title-case to all words in string except for nominated acronyms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM