summaryrefslogtreecommitdiff
path: root/ext/spl/examples/seekableiterator.inc
diff options
context:
space:
mode:
Diffstat (limited to 'ext/spl/examples/seekableiterator.inc')
-rwxr-xr-xext/spl/examples/seekableiterator.inc16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/spl/examples/seekableiterator.inc b/ext/spl/examples/seekableiterator.inc
new file mode 100755
index 0000000000..157d2736f4
--- /dev/null
+++ b/ext/spl/examples/seekableiterator.inc
@@ -0,0 +1,16 @@
+<?php
+
+class SeekableIterator implements Iterator
+{
+ function seek($index) {
+ $this->rewind();
+ $position = 0;
+ while($position < $index && $this->it->hasMore()) {
+ $this->next();
+ $position++;
+ }
+ return $position;
+ }
+}
+
+?> \ No newline at end of file