{ public function seek($index) { if ($index < count($this->a)) { $this->i = $index; } echo __METHOD__ . '(' . $index . ")\n"; } } $a = array(1, 2, 3, 4, 5); $it = new LimitIterator(new NumericArrayIterator($a), 1, 3); foreach ($it as $v) { print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; } echo "===SEEKABLE===\n"; $a = array(1, 2, 3, 4, 5); $it = new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3); foreach ($it as $v) { print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; } echo "===STACKED===\n"; echo "Shows '2 is greater than 2' because the test is actually done with the current value which is 3.\n"; $a = array(1, 2, 3, 4, 5); $it = new CachingIterator(new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3)); foreach ($it as $v) { print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; } ?> ===DONE=== <?php exit(0);