Use the following function to list the contents of one or more nested directories.
function recursive_directory($dirname,$maxdepth=10, $depth=0){ if ($depth >= $maxdepth) { return false; } while (false !== ($f = $d->read())) { $file = $d->path.'/'.$f; // skip . and .. if (('.'==$f) || ('..'==$f)) { continue; }; } else { }; }; $d->close(); foreach ($subdirectories as $subdirectory) { }; } return $files; }
Use this in the following way.
$files = recursive_directory('folder');
The maximum depth that the function will travel down is set to 10 as a default. This can be overwritten at runtime.
$files = recursive_directory('folder', 20); // make maximum level 20
0 comments:
Post a Comment