4th June 2009 - 4 minutes read time
If you are constructing a simple string from a set of variables contained in an array then you can use the implode function to convert the array into a string. The implode() function takes two parameters. The first is the glue that is used to join the items in array together and the second is the array to use. Here is a trivial example of implode() in action.
$array = array(1, 2, 3, 4, 5, 6);
echo implode(',', $array);
This will print out the following:
1,2,3,4,5,6
The good thing about the implode() function is that it doesn't add stray commas to the start and end of the string so there is no need to alter the string after the function is used.