PHP shopping carts and Key Value Pairs
Posted on 2007-03-31
I am attempting to create a PHP shopping cart using a session. Below is the code I have so far for adding to the cart.
$cart = $_SESSION['cart'];
$cart[sizeof($cart)+1] = $_GET['pid'] ;
$_SESSION['cart'] = $cart;
I want to store the quantity ordered as a key value pair in the array. I have tried this using the below code, without any luck. How do I do this?
$cart[sizeof($cart)+1] = ($_GET['pid'] => $_GET['quantity']);