3v4l.org

run code in 200+ php & hhvm versions
<?php $items = new ArrayObject(range(1,11)); echo 'there are ' . $items->count() . ' total items' . "\r\n"; $itemIterator = $items->getIterator(); $cachingIterator = new CachingIterator($itemIterator); $limitIterator = new LimitIterator($cachingIterator, 0, 10); $i = 0; foreach ($limitIterator as $item) { ++$i; } echo 'first page has ' . $i . ' items' . "\r\n"; var_dump($cachingIterator->hasNext() === $itemIterator->valid());
based on AeUk7
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.28 - 7.2.9
there are 11 total items first page has 10 items bool(true)