php implode array elements

php implode array elements


Join array elements with a string string.
implode(string, arraypieces)
Returns a string containing a string representation of all the array elements in the same order,
 string between each element.
 Example 1. Implode() example
$dash = implode ("-", $array);
  join(), andsplit().

 join(string, arraypieces)

The implode() function inserts a comma after every array element and returns a string with the inserted commas. We eliminate the last two characters of the string by using the substr() function because we do not need to print the trailing ', '. This is a very useful function for printing out entire arrays. In PHP, when you print $list; where $list is an array, PHP prints "array" instead of the elements of an array.

The array_unique() function will, given an array, strip the array of all its duplicate items and return a new array. The array_unique() function works on both associative and numerically indexed arrays.