You might try using foreach/unset, instead of array_shift. <?php // Task: get and remove the first element of the array
$array = array(0, 1, 2, 3, 4, 5);
foreach($array as $value)
{
// with each pass get the value
// use method to doSomethingWithValue($value);
echo $value;
// and then remove that from the array
unset($array[$value]);
}
//so at the end of 56 rounds the array will be empty
assert('empty($array) /* Array must be empty. */');
?>