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

2004-02-19 Thread Chris
You have two separate problems here: 1) unset($_SESSION["cart_array"], $item) This unsets $_SESSION["cart_array"] and also $item, it should be unset($_SESSION["cart_array"][$item]) 2) The method of unsetting session variables depends on whether you have register_globals on, it's all here: htt

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