The SPL is one of hardest things to grasp for most PHP developers. But why is this? The lack of documentation inside the
manual, the fact that there are not many real-life examples, or maybe it’s just too hard? In this post I will try to
explain a bit more about the “iteratorAggregate”
interface. Together with its more famous brother Iterator
, they are currently the two only implementations of the
Traversable
interface, which is needed for objects so they can be used within a standard foreach()
loop. But why and
when should we use the iteratorAggregate
?