PHP function: implode()

I learned something new about the implode function the other day, namely that the order of the parameters does not matter. Ordinarily you would give the “glue” and then the array in that order, but the function will work the same if you provide them in reverse as well. I will just determine which is the string and which is the array and use the properly.

$glue = ",";
$array = array('hello', 'world');
echo implode($glue, $array) // echos hello,world
echo implode($array,$glue) // echos hello,world

Leave a Reply