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?

1
  • There is no callback or hook exposed by lmpload() to allow this. Commented Sep 11, 2011 at 4:56

1 Answer 1

21

You could do:

echo implode(', ', array_map("ucfirst", $values));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.