开发者

call function on imploded value?

开发者 https://www.devze.com 2023-04-03 20:44 出处:网络
I have an ar开发者_开发知识库ray of values, the values are all in lower case, I want to call ucfirst() on the values.

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));
0

精彩评论

暂无评论...
验证码 换一张
取 消