Hi Marc
Please take a look at the thread headed 'Iterator Class/foreach Logic Flaw?'
- you will find your hasMore() returns TRUE when place on the last element,
but (in the exammple code below), there are only three elements - therefore
when on the third element, hasMore() should return false...
Hi,
I used to implement the hasMore() method like this:
public function hasMore(){
if (key($this->container) === NULL ) return FALSE;
if ( (key($this->container)) <=
(count($this->container)-1) )
{
return TRUE;
}else
return FALSE;
}
And I think that is what
The following code attempts to use a class's iterator member with foreach.
This code will not run unless you comment out the offending foreach (marked
'** Comment out the next three lines...').
As demonstrated, it is possible to get() the iterator class and run it using
foreach() externally or to