RE: [PHP] Can't remove an element from an array

2004-02-19 Thread Chris
t; To: [EMAIL PROTECTED] > Subject: [PHP] Can't remove an element from an array > > > Hi, I have an array that holds the item_id's for a shopping cart. I am > trying to remove the item specified by a GET like this: > > foreach ($_SESSION["cart_array"] as $i

Re: [PHP] Can't remove an element from an array

2004-02-19 Thread John Nichel
Brian Dunning wrote: Hi, I have an array that holds the item_id's for a shopping cart. I am trying to remove the item specified by a GET like this: foreach ($_SESSION["cart_array"] as $item) { if ($item==$_GET["item_id"]) {unset($_SESSION["cart_array"], $item); break;} } But it removes ALL i

[PHP] Can't remove an element from an array

2004-02-19 Thread Brian Dunning
Hi, I have an array that holds the item_id's for a shopping cart. I am trying to remove the item specified by a GET like this: foreach ($_SESSION["cart_array"] as $item) { if ($item==$_GET["item_id"]) {unset($_SESSION["cart_array"], $item); break;} } But it removes ALL items from the cart. An