Javatpoint Logo
Javatpoint Logo

PHP string Implode() Function

PHP implode() is a string function, which joins the array elements in a string. It is a binary-safe function. In implode() function, parameters can be passed in any order.

The implode() function works same as the join() function and returns a string created from the elements of the array. Basically, this function joins all elements of array in one string.


There are two syntax are available for implode() function, which are given below:


Join the array elements by $glue string parameter.


There are two parameters can be passed in the implode() function, one of which is mandatory, and another one is optional. These parameters are as follows:

$glue (optional):

It is an optional and string type of parameter. It contains the value to join the array elements and form a string. Basically, $glue is used to join the string.

$pieces (mandatory):

This parameter contains the array of string to implode. The array elements are mandatory to pass in implode() function to join into one string.

Return Value

The implode() function returns the string formed from the array elements. The string will be formed in the same order as elements passed into array. The return type of this function is string.


After PHP version 7.4.0, passing the $glue parameter after the $pieces parameter has been deprecated.


Example 1:

In the below example, array elements are joined with + operator using implode() function.


Before using 'implode()' function:
array('Welcome', 'to', 'PHP', 'tutorial')

After using 'implode()' function:

Example 2:


Noida, Delhi, Gurugram

Example 3:

In the below example, two arrays are joined together using implode() function.


Hello everyone! / Welcome to Javatpoint

Next TopicPHP String

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA