159 of 410 menu

The implode Function

The implode function merges an array into a string with a specified separator.

Syntax

implode(string $separator, array $array): string

Example

Let's merge an array into a string:

<?php $arr = ['a', 'b', 'c', 'd', 'e']; echo implode('-', $arr); ?>

Code execution result:

'a-b-c-d-e'

Example

Using an empty separator:

<?php $arr = ['a', 'b', 'c', 'd', 'e']; echo implode('', $arr); ?>

Code execution result:

'abcde'

See Also

  • the explode function,
    which splits a string into an array
byenru