Iterating through a multidimensional array with foreach()
<?
$flavors = array('Japanese' => array('hot' => 'A',
'salty' => 'B'),
'Chinese' => array('hot' => 'D',
'pepper-salty' => 'C'));
foreach ($flavors as $culture => $culture_flavors) {
foreach ($culture_flavors as $flavor => $example) {
print "A $culture $flavor flavor is $example.\n";
}
}
?>
Related examples in the same category