Multidimensional Arrays
<p>I have a function that adds custom built cameos in a cart. The cart is stored in a session variable. If the customer decides to build the very same cameo I don't want to add another entry to the array I just want to be able to add 1 more to the quantity of said product. The problem is when the scripts reaches the point where it's checking to see if the values exist in the array it returns false and adds a new entry to the array. I am fairly new to php so I'm not sure if I am going about it the right way. </p>

<pre><code>function AddToCart($subpid,$subtype,$subprice,$subtotal,$subcarving,$subline1,$subline2){
    global $form;

    $exist = false;
    $i=0;

    if(!isset($_SESSION['cart'])){
        $_SESSION['cart'] = array(0 =&gt; array("Product ID" =&gt; $subpid, "Type" =&gt; $subtype, "Price" =&gt; "$".$subprice, "Subtotal" =&gt; "$".$subtotal, "Carving" =&gt; $subcarving, "Line 1" =&gt; $subline1, "Line 2" =&gt; $subline2, "Quantity" =&gt; 1));
    }
    else{
        foreach($_SESSION['cart'] as $item){
            $i++;
            while(list($key,$value) = each($item)){
                /* If product exist add 1 to quantity */
                if($key == "Product ID" &amp;&amp; $value == $subpid &amp;&amp; $key == "Type" &amp;&amp; $value == $subtype &amp;&amp; $key == "Price" &amp;&amp; $value == "$".$subprice &amp;&amp; $key == "Subtotal" &amp;&amp; $value == "$".$subtotal  &amp;&amp; $key == "Carving" &amp;&amp; $value == $subcarving &amp;&amp; $key == "Line 1" &amp;&amp; $value == $subline1 &amp;&amp; $key == "Line 2" &amp;&amp; $value == $subline2){
                    array_splice($_SESSION['cart'], $i-1, 1, array(array("Product ID" =&gt; $subpid, "Type" =&gt; $subtype, "Price" =&gt; "$".$subprice, "Subtotal" =&gt; "$".$subtotal, "Carving" =&gt; $subcarving, "Line 1" =&gt; $subline1, "Line 2" =&gt; $subline2, "Quantity" =&gt; $item['Quantity'] + 1)));
                    $exist = true;
                }
            }
        }
        if($exist == false){
            array_push($_SESSION['cart'], array("Product ID" =&gt; $subpid, "Type" =&gt; $subtype, "Price" =&gt; "$".$subprice, "Subtotal" =&gt; "$".$subtotal, "Carving" =&gt; $subcarving, "Line 1" =&gt; $subline1, "Line 2" =&gt; $subline2, "Quantity" =&gt; 1));
        }
    }
    return 0;
}
</code></pre>

<p>If I was to just use: $key == "Product ID" &amp;&amp; $value == $subid it will return true and update the quantity but the problem with that is if the customer buys two cameo with the same id but different carving on it or engravings my cart will be off.</p>
