Multi-dimensional arrays work the same as non-nested arrays. You just need to look at how to access them the same.

For example:
Next ($cat_data);
versus:
Next ($cat_data[0]);
or even:
$row =& $cat_data[1];
//notice the use of a reference & (to keep from using a copy)
Next ($row);

Well, have fun ...

Jason k Larson


@ Nilaab wrote:

Hello Everyone,

I have a multi-dimensional array called $cat_data, and I need to access
certain elements in the array using the next() and prev() functions. I did
consider using loops like for, foreach, and while...but for this particular
application, I don't want to loop through the entire array. Also, I need
everything in that array, so no I don't want to limit the data drawn from
the database. I know the two above mentioned functions work with normal
arrays, but how would I make it work with multi-dimensional arrays? The
following is a little idea of the structure of the array:

$cat_data[$a][$b] where $a is the row number from the database, and $b is
the column being accessed.

$cat_data[0][0] = the first row of the id column.
$cat_data[0][1] = the first row of the name column.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to