-
hi all,
i have a couple of nested loops within my php script, and within the second loop i need to create a new array dynamically and put the value of an expression in it.
the loops are: outer loop increments i by 1, inner loop increments j by 1.
now, the dynamic array bit as i attampted it was:
"$row".$i."[".$j."]"=$slicesxmax[$i]-$slicesxmin[$i];
(clearly rubbish )
what i am trying to do on the left hand side is:
assign a value to (and therefore create) an array called
$row, plus the value of i (e.g. $row1,$row2), and use the value of j to determine which slot in the array would be filled. the outcome would be something like:
inner loop
$row0[0]=
$row0[1]=
$row0[2]=
(etc.)
outer loop
$row1[0]
$row1[1]
(etc.)
hopefully this makes sense . i have experimented around and havent succeded in getting this to work, any ideas?
thx in advance
bob
-
Hi,
you can have multidimensional arrays...
$row = array();
$row[0] = array(3, 4, 5);
print $row[0][1];
You should probably create the subarrays like this
$row = array();
$row[0] = array();
$row[1] = array();
Musicman
-
Nice. There's a great article on array manipulation at DevShed:
http://www.devshed.com/Server_Side/P...nip/page1.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|