Harley1979 Posted June 24, 2008 Share Posted June 24, 2008 Hello, Programing really isn't my strongest point so I'm after a little help here with something. I am writting a simple shopping cart, what I specifically need to know is this. If I write two id's into a multi-dimensional array; $_SESSION['productItem'] = $productItem; $_SESSION['productSize'] = $productSize; $productItem .= ','.$_REQUEST['itemID']; $productSize .= ','.$_REQUEST['sizeID']; $myArray = ($productItem, $productSize); How can I extract and seperate $productItem and $productSize again? The sizes are pulled from a seperate table in the database so it is important that I'm able to extract the $productSize array for this functionality. How would I best approach this? Thanks Link to comment https://forums.phpfreaks.com/topic/111651-multi-dimensional-array-question/ Share on other sites More sharing options...
trq Posted June 24, 2008 Share Posted June 24, 2008 The code you've posted doesn't create a multidimensional array. Link to comment https://forums.phpfreaks.com/topic/111651-multi-dimensional-array-question/#findComment-573102 Share on other sites More sharing options...
shelluk Posted June 24, 2008 Share Posted June 24, 2008 If I understand you correctly. Change your line to: $myArray = array($productItem, $productSize); Then read with $myArray[0] or $myArray[1]. For example: <?php $_SESSION['productItem'] = $productItem; $_SESSION['productSize'] = $productSize; $productItem .= ','.$_REQUEST['itemID']; $productSize .= ','.$_REQUEST['sizeID']; $myArray = array($productItem, $productSize); //To test echo "Item ".$myArray[0]." and size ".$myArray[1]; ?> Link to comment https://forums.phpfreaks.com/topic/111651-multi-dimensional-array-question/#findComment-573136 Share on other sites More sharing options...
shelluk Posted June 24, 2008 Share Posted June 24, 2008 Meant to add.. which yes isn't multidimensional but I don't see where that is needed. There is only 2 items appearing once? Why is an array even needed? Link to comment https://forums.phpfreaks.com/topic/111651-multi-dimensional-array-question/#findComment-573138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.