Iterators could save your day on many occasions. Everyone has already been bothered by memory overflows when trying to manage too big collections in PHP. These are omnipresent in the most famous PHP libraries: Symfony, Doctrine, PHPUnit and even the SPL. The latter contains a lot of ready-to-use iterators that will allow you to manage collections of any size, without ever having to worry about memory. You won’t be able to do without Iterators and Generators soon!

Comments

Please login to leave a comment

Mike Lehan at 16:33 on 15 Mar 2024

An Ideal overview of this topic and well demonstrated with a live demo. Would have been interesting to see an actual comparison with memory values, especially from the Doctrine perspective.

Nice and good explanation of generators and iterators. Would loved to see the actual numbers that proof the improvements.