summaryrefslogtreecommitdiff
path: root/ext/spl/examples/limititerator.inc
diff options
context:
space:
mode:
Diffstat (limited to 'ext/spl/examples/limititerator.inc')
-rwxr-xr-xext/spl/examples/limititerator.inc8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/spl/examples/limititerator.inc b/ext/spl/examples/limititerator.inc
index c1a19fedd9..cdc71e98ce 100755
--- a/ext/spl/examples/limititerator.inc
+++ b/ext/spl/examples/limititerator.inc
@@ -21,8 +21,12 @@ class LimitIterator implements Iterator
{
$this->it->rewind();
$this->index = 0;
- while($this->index < $this->offset && $this->it->hasMore()) {
- $this->next();
+ if (is_a($this->it, 'SeekableIterator')) {
+ $this->index = $this->it->seek($this->offset);
+ } else {
+ while($this->index < $this->offset && $this->it->hasMore()) {
+ $this->next();
+ }
}
}