Last active
August 29, 2015 14:05
-
-
Save jeremeamia/6ab49df836bc8e59262b to your computer and use it in GitHub Desktop.
Demonstrates that the IteratorIterator must be rewound before it is valid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $iter = new IteratorIterator(new ArrayIterator(range('a', 'z'))); | |
| var_dump($iter->valid(), $iter->key(), $iter->current()); | |
| #> bool(false) | |
| #> NULL | |
| #> NULL | |
| $iter->rewind(); | |
| var_dump($iter->valid(), $iter->key(), $iter->current()); | |
| #> bool(true) | |
| #> int(0) | |
| #> string(1) "a" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment