After using this function, the traversable's pointer will point at the end. Examples 2 and 3 highlight this using code.
This means that when you call iterator_count($foo)...
- Before a foreach-loop on $foo, the loop will not execute because it's already at the end. Calling $foo->rewind() will reset the traversable to the beginning.
- Inside a foreach-loop on $foo, the loop will complete the current iteration and not repeat. Something like $foo->seek($i) can be used to reset the pointer, where $i contains the pointer's value prior to counting.