php - Cant call multidimensional array -
i trying create cart system ajax , multidimensional session array. array stores product id , quantity of id. trying display quantity of 1 of these stored id's right value not returned.
here php code
public function create() { session_start(); $product_id = $_get['data']; // check if cart has been created if(isset($_session['cart']) , $_session['cart'] != null) { // 1 or more items have been placed in cart }else{ // cart empty $_session['cart'] = array(); $_session['cart'][$product_id] = array('quantity' => 3); } // return quantity of stored product id return $_session['cart'][$product_id]['quantity']; }
as can see number 3 should returned. instead value 1.
Comments
Post a Comment