This may be a stupid question, so please go easy on me if so.
I have a range of queries (MySQL) returning multidimensional arrays.
I then use these array items to populate variables in a string in a foreach loop.
I then need this string to populate a javascript graph so the format of the data wants to be perfect. this idea works with 1 multidimensional array.
However. To do multiple graphs (e.g comparison line graph) I need to express all the data in the same row.
So what I need to be able to do is if possible merge row to row of the array, rather than add it to the end.
Ill show you my working:
foreach ($graph_month as $month) :
$first .= ' { year: "'.$month['month'].'",';
endforeach;
foreach ($graph_data1 as $data) :
$second1 .= ' "'.$data['title'].'": '.$data['totalValue'].' ';
endforeach;
foreach ($graph_data2 as $data) :
$second2 .= ' "'.$data['title'].'": '.$data['totalValue'].' ';
endforeach;
foreach ($graph_data3 as $data) :
$second3 .= ' "'.$data['title'].'": '.$data['totalValue'].' ';
endforeach;
foreach ($graph_data4 as $data) :
$second4 .= ' "'.$data['title'].'": '.$data['totalValue'].' ';
endforeach;
foreach ($graph_data5 as $data) :
$second5 .= ' "'.$data['title'].'": '.$data['totalValue'].' ';
endforeach;
So each of the foreach's is populating a little section of the javascript required, however I need to be able to concatenate all these rows on the right of each other.
e.g
a foreach that can produce:
$first.$second1.$second2.$second3.$second4.$second5
Is this possible, would it be possible to add [i] and [i++] to each variable.