I am building a shopping cart using session variables. I can push the array to the session array like this:
//initialize session cart array
$_SESSION['cart'] = array();
//store the stuff in an array
$items = array($item, $qty);
//add the array to the cart
array_push($_SESSION['cart'], $items);
So far, so good. The problem is in removing an item from the cart. When I try to use this, I get a array to string conversion error.
//remove an array from the cart
$_SESSION['cart'] = array_diff($_SESSION['cart'], $items);
To clarify, the question here is why is the above statement creating an array to string conversion error?