implode()
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.
Syntax
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.
Example
The example below uses the implode()
function to create the sentence ‘I love learning with Codecademy’. The separator is a single space.
<?php$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
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.