Here is a simple iterator interface definition for PHP 4. Please note that this interface doesn't complay with the SPL (Standard PHP Library).
/** * Define Iterator interface. * The iterator interface allows client to traverse objects in a collection. * * @author Ivan Georgiev * @abstract */ class ig_Iterator { /** * Checks whether the collection has more elements to traverse. * If this method returns true, it is safe to use the {@link next} method * to retrive the next element in collection. * @return boolean Returns true if there are still elements to traverse. * @abstract */ function hasNext() { } /** * Retrieves and returns the next element in collection. * Client should use the {@link hasNext} method to check if element is * available before calling this method. * @return Object * @abstract */ function & next() { } }
Known Implementations: Array Iterator in PHP
See also: PHP Collection Interface, PHP Array Collection, PHP Array Iterator