Looping the Loop with SPL Iterators
summary
SPL Iterators are shown to reduce complexity and improve readability by replacing arrays with iterable objects like IteratorAggregate that wrap a PDO statement and yield rows, effectively creating a rewindable generator by re-executing the query. Examples include nesting LimitIterator, CallbackFilterIterator, RegexIterator and filesystem iterators to build composable filters and infinite sequences; a concrete claim is that FixedArray saves about 20% less memory and iterators generally use far less memory than loading huge arrays, and the patterns demonstrated work as described.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 3:04What is an Iterator
- 5:36Array Iterator
- 9:06Real Code
- 13:30SPL Iterators
- 15:17Infinite Iterator
- 16:17Callback Iterator
- 18:33Generator Iterator
- 19:52Iterator Aggregate
- 22:51Useful Links
- 23:58Books








