Given this two-dimensional array, each element has two indexes – row and column.
foreach($shop as $items){
echo $items[0]." costs ".$items[1]." and you get ".$items[2]."<br />";
}
foreach seems more simple for me, plus it would handle if your key are not numeric like
array( 'foo' => array("rose", 1.25 , 15),
'bar' => array("daisy", 0.75 , 25),
'foobar' =>array("orchid", 1.15 , 7)
);
personally I avoid to use for
in PHP because it's less flexible then foreach
in most case.
You could also use
foreach($shop as $shoprow)