Re: How To Use The next() and prev() functions on multi-dimensional arrays
| From: | Jason k Larson | Date: | Fri, 27 Dec 2002 06:41:06 +0000 |
| Subject: | Re: How To Use The next() and prev() functions on multi-dimensional arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129412@lists.php.net to get a copy of this message | ||
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.