Combining array implode ()

June 21, 2009, Posted by admin at 6:00 am

Combining array elements into a string

string implode (string glue, array pieces)

Returns a string with a string representation of all array elements in the same order as in the array where each array element with the specified parameters glue string connected.

<? php
$ array = array ( ‘lastname’, ‘email’, ‘phone’);
$ comma_separated = implode ( “”, $ array);
print $ comma_separated, / / lastname, email, phone
?>

Note: implode () command accepts the parameters for historical reasons in the two sequences. However, you should have because of the consistency with explode () the documented and probably less confusing order of the arguments used.

implode () is the opposite of explode ()

No comment yet.

You must be logged in to post a comment.