in reply to Why does a full iteration over array & shift is not emptying the array

... and here is a quote from the documentation (For Loops):
If any part of LIST is an array, foreach will get very confused if you add or remove elements within the loop body, for example with splice. So don't do that.
  • Comment on Re: Why does a full iteration over array & shift is not emptying the array