implode
Using PHP implode() To Construct Strings
Thu, 06/04/2009 - 09:33 | by philipnorton42If 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:
Print Array Without Trailing Commas In PHP
Fri, 04/24/2009 - 09:10 | by philipnorton42I 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.