Created
August 8, 2014 18:57
-
-
Save jeremeamia/33fb8c543c3ba1458059 to your computer and use it in GitHub Desktop.
Some iterators need to be rewound and some don't
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 | |
| $iter1 = new LimitIterator(new ArrayIterator(range('a', 'z')), 0, 5); | |
| var_dump($iter1->valid(), $iter1->key(), $iter1->current()); | |
| #> bool(false) | |
| #> NULL | |
| #> NULL | |
| $iter2 = new MultipleIterator(); | |
| $iter2->attachIterator(new ArrayIterator(range('a', 'z'))); | |
| var_dump($iter2->valid(), $iter2->key(), $iter2->current()); | |
| #> bool(true) | |
| #> array(1) { | |
| #> [0] => | |
| #> int(0) | |
| #> } | |
| #> array(1) { | |
| #> [0] => | |
| #> string(1) "a" | |
| #> } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment