Page 1 of 1

Dynamic variabel names in Arrays

Posted: Sat Nov 03, 2007 5:16 pm
by kritro
I have a php script that makes multiple sql query's that results
multiple datasets that I will use in a graph.

Its set up something like this.


for($i=0; $i<$n; $i++){
sql query runs here n times and produce each time a dataset that looks like.

2007-10-17 3
2007-10-18 4
2007-10-19 2

I want to put each dataset in an Array with diferent name.
I manage to put on dataset it in one array

$ydata[] = $row[1];
$xdata[] = $row[0];

}

but I need one array of every dataset with names that I can recognize
outside the loop, for eks a dynamic variabel name that consist of
$i and some other name.

like $i.$xdata[], but I cant make this work.

Anyone now how to do this I would be very grateful.

kritro

Posted: Sat Nov 03, 2007 6:32 pm
by s.dot

Code: Select all

${$i.$xdata}[]

Posted: Sat Nov 03, 2007 8:05 pm
by feyd
Badness. The logic needs rethinking. i.e. multidimensional array, not multiple one-dimensional arrays.