I know this has been asked quite a few times but this is a bit of a twist.
I have a multidimensional array in which the Key of the array needs to be the column name for a flat csv-type string (I don't want it as a file, just as a csv string).
So it's like this:
$data = array(
dates = array ('2010-01-02','2011-02-03','2011-02-04'),
type1 = array ('data1','data2','data3'),
type2 = array ('data4','data5','data6')
);
The end result should be:
$new_data = "dates,type1,type2" . "\n"
$new_data .= "2010-01-02,data1,data4" . "\n"
$new_data .= "2011-02-03,data2,data5" . "\n"
$new_data .= "2011-02-04,data3,data6";
I hope this is clear. Thanks for any help.