Skip to content

Instantly share code, notes, and snippets.

@jipeprojects
Created January 23, 2013 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jipeprojects/4608519 to your computer and use it in GitHub Desktop.
Save jipeprojects/4608519 to your computer and use it in GitHub Desktop.
PHP recursive directory path with RecursiveIteratorIterator in combination with RecursiveDirectoryIterator
$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