implode

Join array elements with a string

&reftitle.description; `string` `implode` `string` `separator` `array` `array`

Alternative signature (not supported with named arguments):

`string` `implode` `array` `array`

Legacy signature (deprecated as of PHP 7.4.0, removed as of PHP 8.0.0):

`string` `implode` `array` `array` `string` `separator`

Join array elements with a `separator` string.

&reftitle.parameters;

`separator`

- Optional. Defaults to an empty string.

`array`

- The array of strings to implode.

&reftitle.returnvalues;

Returns a string containing a string representation of all the array elements in the same order, with the separator string between each element.

&reftitle.changelog;

&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.

&reftitle.examples;

### `implode` example

    <?php

    $array = ['lastname', 'email', 'phone'];
    var_dump(implode(",", $array)); // string(20) "lastname,email,phone"

    // Empty string when using an empty array:
    var_dump(implode('hello', [])); // string(0) ""

    // The separator is optional:
    var_dump(implode(['a', 'b', 'c'])); // string(3) "abc"

    ?>

&reftitle.notes; ¬e.bin-safe;
&reftitle.seealso;

- `explode`
- `preg_split`
- `http_build_query`