24th April 2009 - 2 minutes read time
I have previously talked about Removing commas from the end of strings, but it is also possible to use the implode() function to do the same sort of thing.
implode() takes two parameters, the separator and the array, and returns a string with each array item separated with the separator. The following example shows how this function works.
$array = array(1,2,3,4,5,6);
$list = implode(',', $array);
The $list variable will now contain the string "1,2,3,4,5,6". However, things tend to become messy again when you have an array with empty items in it.