tarun Posted March 24, 2007 Share Posted March 24, 2007 This Is A Quick Multi Dimensional Array That Ive Put Together <?php $itemList = array( '000001'=>array('ID' => '000001','name' => 'Item 1','price' => '99.99','img' => 'images/1.jpg','cat' => 'Category 1'), '000002'=>array('ID' => '000002','name' => 'Item 2','price' => '49.99','img' => 'images/2.jpg','cat' => 'Category 2') ); ?> How Do I List The Items Info Using foreach Thnx, Tarun Link to comment https://forums.phpfreaks.com/topic/44144-multi-dimensional-array-foreach/ Share on other sites More sharing options...
fert Posted March 24, 2007 Share Posted March 24, 2007 foreach($itemList as $key=>$value) { foreach($value as $k=>$v) { /*do stuff here*/ } } Link to comment https://forums.phpfreaks.com/topic/44144-multi-dimensional-array-foreach/#findComment-214345 Share on other sites More sharing options...
Barand Posted March 24, 2007 Share Posted March 24, 2007 As your array key is the ID you don't need to repeat it in the array values. Link to comment https://forums.phpfreaks.com/topic/44144-multi-dimensional-array-foreach/#findComment-214431 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.