문제

I have an array 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));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top