Unset array element inside a foreach loop
<p>So here is my code:</p>

<pre><code>&lt;?php

$arr = array(array(2 =&gt; 5),
             array(3 =&gt; 4),
             array(7 =&gt; 10));

foreach ($arr as $v) {
    $k = key($v);
    if ($k &gt; 5) {
        // unset this element from $arr array
    }
}

print_r($arr);

// now I would like to get the array without array(7 =&gt; 10) member
</code></pre>

<p>As you can see, I start with an array of single key => value arrays, I loop through this array and get a key of the current element (which is a single item array).</p>

<p>I need to unset elements of the array with key higher than 5, how could I do that? I might also need to remove elements with value less than 50 or any other condition. Basically I need to be able to get a key of the current array item which is itself an array with a single item.</p>
