Created
January 23, 2013 15:53
-
-
Save jipeprojects/4608519 to your computer and use it in GitHub Desktop.
PHP recursive directory path with RecursiveIteratorIterator in combination with RecursiveDirectoryIterator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$path = realpath('/path/you/want/to/search/in'); | |
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); | |
foreach($objects as $name => $object){ | |
if($object->getFilename() === 'work.txt') { | |
echo $object->getPathname(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment