PHP implode() function

The PHP implode() functions converts array to string using given separator. By using implode() function you can join all the array elements and form a string. implode() function works as same as the join() function in PHP. The implode function is binary safe and you can pass the array elements in any order.

Basic Syntax

string implode(separator,array)
separatorThis is optional parameter used to place between two array elements. The default value is “”.
arrayarray of elements to convert to string.

Return Value

The php implode function returns the string formed using array elements.


Following are the examples of implode() method.

1. Separating array elements by spaces using implode() function

The output should be:

Apple Banana Cat Dog Elephant

2. Separating array elements by comma using implode() function

The output should be:



Please enter your comment!
Please enter your name here