[英]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);
将ucfirst
和array_map
与strtolower
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.