title: Multidimensional array in php SESSION
body: <p>I am having problem with updating an array element with in <code>$_SESSION</code> variable of PHP. This is the basic structure:</p>
  
  <pre><code>$product = array();
  $product['id'] = $id;
  $product['type'] = $type;
  $product['quantity'] = $quantity;
  </code></pre>
  
  <p>And then by using <code>array_push()</code> function I insert that product in SESSION variable.             </p>
  
  <pre><code>array_push($_SESSION['cart'], $product); 
  </code></pre>
  
  <p>Now this is the main part where i m facing problem:</p>
  
  <pre><code>foreach($_SESSION['cart'] as $product){
  
      if($id == $product['id']){
          $quantity = $product['quantity'];
          $quantity += 1;
          $product['quantity'] = $quantity;       
      }
  
  }
  </code></pre>
  
  <p>I want to increment product quantity within <code>$_SESSION['cart']</code> variable. How can I do that?</p>