Remove first element from simple array in loop
<p>This question has been asked a thousand times, but each question I find talks about associative arrays where one can delete (unset) an item by using they key as an identifier. But how do you do this if you have a simple array, and no key-value pairs?</p>

<p>Input code</p>

<pre><code>$bananas = array('big_banana', 'small_banana', 'ripe_banana', 'yellow_banana', 'green_banana', 'brown_banana', 'peeled_banana');

foreach ($bananas as $banana) {
    // do stuff
    // remove current item
}
</code></pre>

<p>In Perl I would work with <code>for</code> and indices instead, but I am not sure that's the (safest?) way to go - even though from what I hear PHP is less strict in these things.</p>

<p>Note that after foreach has run, I expected <code>var_dump($bananas)</code> to return an empty array (or null, but preferably an empty array).</p>