try doing this for each item: $cartArray[] = array('itemnumber' => $itemnumber, 'brand' => $brand, 'quantity' => $itemqty, 'name' => $itemname);
-js Jonathan Duncan wrote: > I am trying to create an array to hold shopping cart information. The array > I am using is called "cartArray". What I want to do is to define a > sub-array of cartArray with the information from one product. Then the next > time a product is added it appends then new information as a second > sub-array to cartArray and so forth. Following is some code I have been > using to test with and so far PHP will let me use ".=" to append but when I > try to call it back with "print_r" or echo array[][] only the first entry is > returned. Any ideas what I am doing wrong? > > -------------------------------------------- > $brand="Brand1"; > $itemnumber="456789"; > $itemname="Some Item Name"; > $itemqty=3; > $cartArray[] .= array(0=>array($itemnumber=>"$brand", "$itemqty", > "$itemname")); > print_r($cartArray)."<BR><BR>"; > $brand="Brand2"; > $itemnumber="123456"; > $itemname="Another Item Name"; > $itemqty=9; > array_push($cartArray, array($itemnumber=>"$brand", "$itemqty", > "$itemname")); > print_r($cartArray)."<BR><BR>"; > echo $cartArray[0][0]."<BR><BR>"; > -------------------------------------------- > > Thank you, > Jonathan Duncan > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php