If I have a class that implements the Iterator interface, I can manually control how iteration in a foreach loop. But are there other ways in which I could make my object behave like an array?
For instance, let's say I have a class Guestbook which implements Iterator, so that I can iterate foreach (new Guestbook() as $entry). But what if I want to, say, reverse the order?
foreach (array_reverse(new Guestbook()) as $entry) definitely won't work, because array_reverse will only accept an array.
I guess what I'm asking is, can I use Iterator for more than just foreach loops?
Thanks.