Re: multidimensional arrays
| From: | Matthew Beers | Date: | Mon, 18 Sep 2000 17:07:10 +0000 |
| Subject: | Re: multidimensional arrays | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2952@lists.php.net to get a copy of this message | ||
Libor,
You could use the foreach statement. If you don't need to know
beforehand the size of the array, you could do something like:
foreach ($arr as $sub_arr) {
$i++;
$j = 0;
foreach ($sub_arr as $value) {
print "arr[$i][$j] = $value <br>";
$j++;
}
}
This assumes that $arr is the multidimension array and the dimensions
are only 2.
At the end, $i would contain the row count and $j would contain the
count of the last row in the matrix.
-Matt
Saturday, September 16, 2000, 2:37:55 AM, you wrote:
LM> hi,
LM> let's say you have a two multidimensional array. my problem is that i create
LM> these arrays dynamicly, and the size of the matrix the array represents
LM> varies. once it's 3x5, and the next time it could be 24x2.
LM> i need to iterate over all the fields of the matrix. how do i get the the
LM> type of the matrix?
LM> i'd use the "count()" function with a one dimensional array, but don't
LM> know
LM> if there's a similar function for multidimensional arrays.
LM> thanks for your help.
LM> regards
LM> Libor Matyas