Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published May 27, 2023
Contribute to Docs

The implode() function accepts an array of elements and an optional separator. It will return a string formed by combining the elements in their exact order along with the optional separator.


implode($separator, $array)

implode() accepts the following parameters:

  • separator - Optional string value. If omitted, the default is an empty string.
  • array - An array of string elements to implode.


The example below uses the implode() function to create the sentence ‘I love learning with Codecademy’. The separator is a single space.

$to_be_imploded = array('I','love','learning','with','Codecademy');
echo implode(' ',$to_be_imploded);

Codebyte Example

The following example shows the use of implode() function with and without the use of the separator.


All contributors

Looking to contribute?

Learn PHP on Codecademy