title: Update product quantity in php session array if item is already there
body: <p>I have implemented simple shopping cart using php.I can add product in cart and it adds to array.i Get my product id on url,when i click add to cart button based on thar url id i fetch product data from database and add to session array,but my problem is when i add same product i get new entry in session and the instead of updating quantity of that product.
  So what code i write to update the cart quantity if produt_id already there.?</p>
  
  <p>This is print_r array value using <code>$_SESSION['cart']</code>.</p>
  
  <pre><code>[cart] =&gt; Array
      (
          [0] =&gt; Array
              (
                  [product-id] =&gt; 1
                  [item] =&gt; mango
                  [unitprice] =&gt; 20
                  [quantity] =&gt; 1
              )
           [1] =&gt; Array
              (
                  [product-id] =&gt;2
                  [item] =&gt; chickoo
                  [unitprice] =&gt; 20
                  [quantity] =&gt; 1
              )
  
      )
  </code></pre>