Jump to content
Killersites Community
makamo66

var_dump of an array shows just one variable

Recommended Posts

The var_dump of the $cart_items array is supposed to show an array of $cart_items with the quantities added together for the same id but it doesn't even show an array, it just shows one value.

session_start();
$cart_items = $_SESSION["cart_items"];
if ( $cart_items == null ) {
    $cart_items = array();
}
if ( isset($_REQUEST["element_id"]) ) {
    $id = $_REQUEST["element_id"];
}

if ( isset($_REQUEST["quantity"]) ) {
    $quantity = $_REQUEST["quantity"];
}

if ( isset($id)  && isset($quantity) ) {
if (isset($cart_items[$id])) {
          $cart_items[$id] += $quantity;

} else {
    $cart_items[$id] = $quantity;
}
}
var_dump($cart_items);

 
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×