Blog posts tagged with 'iterators':



SPL: Using the iteratorAggregate interface

Date: 04 Dec 2011
Tags: [ iterators ]  [ PHP ]  [ spl

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?

Read more...