|
Posted by Michael Fesser on 01/08/08 07:01
..oO(Steve)
>yes, that's what i meant. as it is though, i haven't really had a need to
>implement an interator on a custom class in php. arrays work fine for just
>about everything in php. i did, however, enjoy reading the article you
>referenced about doing just that - custom classes implementing iterators.
I find it quite useful. In my own framework for example I have a class
TSitemap that holds a representation of all the documents on a website.
It contains a tree-like structure of simple page objects, which store
the name, title, URL path, description, access permissions etc. for
nearly every page. This sitemap is mainly used to automatically generate
nav bars (main menu, sub menus, breadcrumbs etc.) and such things, but
from time to time it's also necessary to directly access a particular
page object from the tree or to iterate over all pages, regardless of
their relation to other pages. To achieve this I simply implement the
ArrayAccess and Iterator interfaces in the TSitemap class.
Micha
[Back to original message]
|