Infinite foreach()¶
Foreach() is built against infinite loops: it works on a finite number of elements in arrays. Using an infinite generator is possible, but cheating with a second infinite loop.
So, the trick is to update the source array during the loop, to keep giving new keys to PHP, that it will check. Over, and over, and over.