Iterating through a multidimensional array with for()
<?
$specials = array( array('A', 'A', 'B'),
array('C','W', 'P') );
for ($i = 0, $num_specials = count($specials); $i < $num_specials; $i++) {
for ($m = 0, $num_sub = count($specials[$i]); $m < $num_sub; $m++) {
print "Element [$i][$m] is " . $specials[$i][$m] . "\n";
}
}
?>
Related examples in the same category