2

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?

Hailwood
  • 89,623
  • 107
  • 270
  • 423

1 Answers1

20

You could do:

echo implode(', ', array_map("ucfirst", $values));
Evgeny Shurakov
  • 6,062
  • 2
  • 28
  • 22