At the risk of making a complete fool of myself, I'd like to ask the smarter brains than me to checkout the current logic in the implementation of Iterator classes and foreach().
The current logic of foreach( $obj as $key => $val ) { ... } where $obj implements Iterator, is: for($obj->rewind(); $obj->hasMore(); $obj->next() ) { ... } but it should be: for($obj->rewind(); $obj->isValid(); $obj->next() ) { ... } As the iterator exits the penultimate interation, next() is called, placing the 'pointer' on the last 'record'. But before the last record is processed, hasMore() is called, which *should* return FALSE, because we have already moved to the last record. The implementations I have seen so far all return TRUE from hasMore() when positioned (i.e. current()) on the last record - this is not logical (Captain). It also prevents proper use of a class implementing an iterator outside of the foreach construct. Philip -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php