Just checking out the iterators in SPL and I can't figure out what the difference is between the two. Examples given for both seem to do the same thing..

    Well, according to

    http://www.php.net/manual/en/class.arrayiterator.php

    When you want to iterate over the same array multiple times you need to instanciate ArrayObject and let it create ArrayIterator instances that refer to it either by using foreach or by calling its getIterator() method manually.

    And I don't see anything in the list of methods declared by ArrayIterator that would allow you to write something like $object[] = "foo";, whereas ArrayObject includes an append() method.

      Write a Reply...