I have an array as such: $items = array( '1'=> array('1'=>'Menu 1 Item 1', '2'=>'Menu 1 Item 2', '3'=>'Menu 1 Item 3'), '2'=> array('1'=>'Menu 2 Item 1', '2'=>'Menu 2 Item 2', '3'=>'Menu 2 Item 3') ); Code (markup): I have a FOR loop that processes this array and prints out the text for each element contained in the two sub-arrays. But now I also need to get the 'number' of the element that is currently being processed too - how can this be done?
this may solve your problem. foreach ($items as $key1=>$item) { echo "Array #$key1 :<br/>"; foreach($item as $key2=>$detail_item) { echo " $key2. $detail_item<br/>"; } } Code (markup): arief