PHP: Implode an array and use each array value multiple times -


what want achieve following:

transform array:

['a','b','c']; 

into string like:

"a a, b b, c c" 

is there other way foreach-loop (like implode) achieve this?

if you're not looking loop through, use array_walk() function.

try this:

$input = ['a','b','c'];  function test_alter(&$item, &$key) {     $item = $item.' '.$item; } array_walk($input, 'test_alter'); echo implode(', ', $input); 

output:

a a, b b, c c 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -