I have an array containing numbers 1-5 (sometimes more). All the members in the array can be displayed using the php function foreach. But, how can I display all the members of my array by storing it in a single variable as csv (like1, 2, 3, 4, 5), and thereby printing that variable only?
-
do you only want to know what's inside the array or do you actually have to work with that variable afterwards?Gordon– Gordon2011-03-07 10:57:20 +00:00Commented Mar 7, 2011 at 10:57
-
i want to work with it afterwards :)Alfred– Alfred2011-03-07 11:10:47 +00:00Commented Mar 7, 2011 at 11:10
Add a comment
|
1 Answer
You could use the function implode().
For example
$csv_var = implode(', ', $array);
Have a look at the Manual.