tarun Posted March 26, 2007 Share Posted March 26, 2007 This Is My QUICK Example items.php Contains The Array <?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') ); ?> add.php Is The Page Which Adds To The Array It Uses include 'items.php'; To Include The Array In The File delete.php Is The Page Which Removes Things From The Array It Also Uses include 'items.php'; To Include The Array In The File BUT How Do I Actually Add And Remove Things To/From THIS Array Thnx, Tarun Link to comment https://forums.phpfreaks.com/topic/44353-adding-and-removing-from-a-multidimensional-array/ Share on other sites More sharing options...
tarun Posted March 26, 2007 Author Share Posted March 26, 2007 BuMp Please... Does AnyOne Know Link to comment https://forums.phpfreaks.com/topic/44353-adding-and-removing-from-a-multidimensional-array/#findComment-215410 Share on other sites More sharing options...
MadTechie Posted March 26, 2007 Share Posted March 26, 2007 see here <?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') ); echo "before<br>"; print_r($itemList); $itemList['000003'] = array('ID' => '000003','name' => 'Item 3','price' => '69.99','img' => 'images/3.jpg','cat' => 'Category 3'); echo "<br><br>after add<br>"; print_r($itemList); echo "<br><br>after remove<br>"; unset($itemList['000003']); print_r($itemList); ?> Oh yeah just incase <?php //to change data $itemList['000003']['name'] = "New data 3"; ?> Link to comment https://forums.phpfreaks.com/topic/44353-adding-and-removing-from-a-multidimensional-array/#findComment-215421 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.