PHP tip: Comma Separated Values (CSV) List to Array and Array to CSV List
from PHP Snippets DB:
// create a comma separated list from an array
$array = array('green','purple','blue','yellow','amber','red');
$comma_separated = implode(",", $array);
echo $comma_separated;
// create an array from a comma separated list
$list = "green, purple, blue, yellow, amber, red";
$array = explode(',', $list);
print_r($array);
Good.
Thanx.
Posted by: Rizwan Pervaiz | Nov 21, 2007 at 10:48 PM
Nice. Thanks for having this available. I knew I could do it with php...and you saved me the time of RTFM...haha. Thanks.
Posted by: Darren Fauth | Feb 17, 2010 at 02:29 PM