implode

string implode(string glue, array pieces) 

Creates a string from array elements.

Returns:

String

Description:

implode() creates a string from an array’s values. The string consists of each value in the pieces array, with the string specified in the glue argument placed between pieces. The values occur in the string in the same order as in the array.

Version:

PHP 3+, PHP 4+

See also:

To split a string into an array of substrings:

explode() 
split() 
join() 

Example:

Illustrate the use of implode()
 <?php $pieces = array ('piece one', 'piece two', 'piece three' ); $glue = '[glue]'; echo "The structure of the \$pieces array is:\n"; var_dump ($pieces); echo "\nCalling \"echo implode ('$glue', \$pieces);\" outputs:\n"; echo implode ($glue, ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.