PHP implode() Function

The implode() function returns a string from the elements of an array.

The implode function is used to “join elements of an array with a string”.

The implode function in PHP is easily remembered as “array to string“, which simply means that it takes an array and returns a string.

$array = array('A','B','C','D');
echo implode(" ",$array);

Output

A B C D

Another Example

$array = array('A','B','C','D');
echo implode(",",$array);

Output

A,B,C,D

Leave a Reply

Your email address will not be published. Required fields are marked *