(PHP 4, PHP 5, PHP 7, PHP 8)
implode — Join array elements with a string
$separator
, array $array
): stringAlternative signature (not supported with named arguments):
$array
): stringLegacy signature (deprecated as of PHP 7.4.0, removed as of PHP 8.0.0):
$array
, string $separator
): string
Join array elements with a separator
string.
separator
Defaults to an empty string.
array
The array of strings to implode.
Returns a string containing a string representation of all the array elements in the same order, with the separator string between each element.
Version | Description |
---|---|
8.0.0 |
Passing the separator after the array
is no longer supported.
|
7.4.0 |
Passing the separator after the array
(i.e. using the legacy signature) has been deprecated.
|
Example #1 implode() example
<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo $comma_separated; // lastname,email,phone
// Empty string when using an empty array:
var_dump(implode('hello', array())); // string(0) ""
?>
Note: This function is binary-safe.