call function on imploded value?
I have an ar开发者_开发知识库ray of values, the values are all in lower case, I want to call ucfirst()
on the values.
I could do
function uc_implode($values){
foreach($values as &$v)
$v = ucfirst($v);
return $values;
}
echo implode(', ', uc_implode($values));
But I am wondering if there is any way to just call ucfirst()
on each value as it is imploded?
You could do:
echo implode(', ', array_map("ucfirst", $values));
精彩评论