summaryrefslogtreecommitdiff
path: root/ext/spl/examples/findfile.php
diff options
context:
space:
mode:
Diffstat (limited to 'ext/spl/examples/findfile.php')
-rwxr-xr-xext/spl/examples/findfile.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/spl/examples/findfile.php b/ext/spl/examples/findfile.php
new file mode 100755
index 0000000000..003111e272
--- /dev/null
+++ b/ext/spl/examples/findfile.php
@@ -0,0 +1,17 @@
+<?php
+
+class FindFile extends SearchIterator
+{
+ protected $file;
+
+ function __construct($path, $file) {
+ $this->file = $file;
+ parent::__construct(new DirectoryTree($path));
+ }
+ function accept() {
+ return !strcmp($this->it->current(), $this->file);
+ }
+}
+
+foreach(new FindFile($argv[1], $argv[2]) as $pathname => $file) echo "$pathname\n";
+?> \ No newline at end of file