"php recursive directory path" Code Answer


Try to use RecursiveIteratorIterator in combination with RecursiveDirectoryIterator

$path = realpath('/path/you/want/to/search/in');

$objects = new RecursiveIteratorIterator(
               new RecursiveDirectoryIterator($path), 

foreach($objects as $name => $object){
    if($object->getFilename() === 'work.txt') {
        echo $object->getPathname();

Additional reading:

  • http://www.phpro.org/tutorials/Introduction-to-SPL.html
By as-28c2ea3cc300 on October 18 2022

Answers related to “php recursive directory path”

Only authorized users can answer the search term. Please sign in first, or register a free account.