[thelist] PHP Multidimensional Array Keys
Gavin Lilley
gavin at crispuk.net
Tue Sep 30 04:46:46 CDT 2003
I am a little stuck with an array. Please help!
matrixArray [Array
(
[1] => Array
(
[unitName] => Unit 2
[15] => Array
(
[topicName] => Tutorial
[2] => Array
(
[matrixKey] => 16
[hours] => 16.00
)
)
[12] => Array
(
[topicName] => Induction
[1] => Array
(
[matrixKey] => 17
[hours] => 6.00
)
[4] => Array
(
[matrixKey] => 18
[hours] => 44.00
)
)
)
)
To loop through the array I can do this:
while (list($key, $value) = each ($unitArray)) { echo "[$key ][
$value ]<br>";}
But I do not know how to 'drill down' through the array. Whats wrong with
the following code?
while (list($key, $value) = each ($unitArray)) {
echo "[$key ][ $value ]<br>";
while (list($keyA, $valueA) = each ($unitArray[$key])) {
echo "[$keyA ][ $valueA ]<br>";
}
}
Appreciate any help.
--
G.
More information about the thelist
mailing list