How do I turn an array into a string?

December 24th, 2011 by Laeeq | 2 comments

If you explode to go one way, then you implode to come back the other way (or use join if you want to type less characters).

Just use the delimiter as the first argument and the array as the second.

Here we go:

<?php

$myarray = array(“I”,”love”,”close”,”up”);

$mystring = implode(” “, $myarray);

echo “$mystring”; //I love close up

?>

You can subscribe to PHPZAG.COM posts by Email

 

 

 

  1. May 10th, 2012 at 08:43 | #1

    Helpful info. Fortunate me I found your site by accident, and I’m stunned why this coincidence did not took place earlier! I bookmarked it.

  2. casino free bets
    December 10th, 2012 at 03:36 | #2

    There is visibly a bunch to know about this. I believe you produced various excellent points in capabilities also.

  1. No trackbacks yet.