iterator_to_array closes the generator gap

A function returning a generator cannot be passed to anything expecting an array — count(), array_map(), json_encode() all fail or produce nonsense. iterator_to_array() is the escape hatch, and its second parameter is the part that catches people.

$rows = iterator_to_array($generator);        // keys preserved
$rows = iterator_to_array($generator, false);  // keys renumbered

By default it preserves keys, and a generator that yields without explicit keys produces 0, 1, 2… — which collides the moment you concatenate two of them. Passing false renumbers instead, which is what you almost always want. Obviously this materialises the whole sequence, so applying it to the million-row generator you just wrote defeats the point of writing it.