Remove an item from an array?
<p>I've created an array from a PHP session variable, and now I'm trying to use ajax (within jQuery) to remove an element from the array.<br />
I've got the following code so far:<br /></p>

<pre><code>$val = $_SESSION['enquiry-basket'];
$array = explode($val);

foreach ($enquiries as $a =&gt; $q) {
    if ($q == $_POST['product_id']) {
        unset($array[$a]);
    }
}
</code></pre>

<p>The only problem is, it doesn't remove the item.<br />
Can anyone explain why, and tell me how to fix it?</p>

<p><strong>Edit</strong></p>

<p>Sorry guys. The reason I mentioned jQuery is because I use a jQuery ajax call to process the PHP I displayed above.<br />
The ajax query runs fine because it processes some javascript goodies (remove's a div from the HTML) once the ajax returns a success.<br />I've added the delimiter (can't believe I missed it) but the element doesn't get removed from the array still.<br />
I've never been good at multi-dimensional arrays, so here's the array printed:<br /></p>

<pre><code>Array ( [0] =&gt; 6 [1] =&gt; 8 ) 
</code></pre>

<p>It looks right to me, but I'm an amateur in arrays. (6 and 8 are of course my strings I inserted)</p>
