php – implode

implode

(PHP 4, PHP 5)

implode — Join array elements with a string

Description
string implode ( string $glue, array $pieces )

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

Example 2284. implode() example

<?php

$array = array(‘lastname’, ’email’, ‘phone’);
$comma_separated = implode(“,”, $array);

echo $comma_separated; // lastname,email,phone

?>

Note: implode() can, for historical reasons, accept its parameters in either order. For consistency with explode(), however, it may be less confusing to use the documented order of arguments.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: