shopping cart: delete doesn't work as supposed to
<p>I'm having some problem with the "delete" of my shopping cart script (is a case of a switch)</p>

<pre><code>case 'delete':
        if ($cart) {
            $items = explode(',',$cart);
            $newcart = '';
            foreach ($items as $item) {
                if ($_GET['id'] != $item) {
                    if ($newcart != '') {
                        $newcart .= ','.$item;
                    } else {
                        $newcart = $item;
                    }
                }
            }
            $cart = $newcart;
            $_SESSION['cart'] = $cart;
        }
        break;
</code></pre>

<p>Example: $_SESSION['cart'] = 1,2,1;
The problem is that when a client bought twice the same item, it deletes both. How can i fix it?</p>
