PHP implode() Function
PHP implode() Function
The implode() function in PHP joins the specified array elements with a string.
Syntax
implode ( string $glue, array $pieces )
Parameter
glue(optional)- It specifies what to put between the array elements.
pieces(required)- This parameter represents the array of strings to implode.
Return
This function returns a string containing a string representation of all the array elements in the same order, with the glue string between each element.
Example 1
Output
Before using implode() function: array('Hello','TutorialandExample') After using 'implode()' function: Hello TutorialandExample
Example 2
Output
Before using the implode() function: array('Hello','TutorialandExample') After using 'implode()' function: Hello+Tutorial+and+Example
Example 3
Output
Before using the implode() function: array('Hello','TutorialandExample') After using 'implode()' function: Hello*Tutorial*and*Example