Hello,
I am working on a shopping cart type script for a report generation facility.
I have been able to add to the cart (a session variable). I want visitors to the site to be able to view the cart contents and remove any or all of the items from the cart($cart). This view part is working ok using javascript to build a second array ($Mid).
I want to compare the contents of the second array ($Mid) with the contents of the original shopping cart array ($cart) to remove the contents of the $cart array elements corresponding the $Mid array.
I have tried looping twice through two "for" loops to check for similarity and then unsetting the required element. However, this is where my logic is breaking down. The unset function does not work with my code. Any ideas where I am going wrong? The code follows....
foreach($Mid as $key=>$value)
{
foreach($cart as $key2=>$value2){
if($value==$value2){unset($cart['$key2']);}
}
}
Is it possible to unset a session variable array ($cart)?
Thanks.