Hi I have a case which is supposed to remove indexes in an array. It messes up all the time. I'm not sure if my code is correct. Let me know if something is out of place.
case "Remove":
$cart = array();
$cart = $_SESSION['cart'];// this is an array (the shopping cart)
$temp = $cart;
for($j=0;$j<count($cart);$j++)
{
if($_POST['item$j'])
{
unset($temp[$j]);
}
}
$cart = array();
$cart = array_merge($temp);
$_SESSION['cart'] = $cart;
$domain = $_POST['domain'];
break;
You can see the script in action here
You'll notice it is not removing the items in cart now. However before I managed to remove some Items but it was very sporadic and never removed items I selected in the cart. I've been stressing for more than 4 hours trying different ways to get it to remove specific items in cart.
Your help will be godsend! Thank you for your interest!