note 28106 deleted from function.is-dir by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:35:14 +0000 |
| Subject: | note 28106 deleted from function.is-dir by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58449@lists.php.net to get a copy of this message | ||
Note Submitter: bigi@agum.com
----
Here is a recursive function that uses is_dir(), to make a list of all subdirectories inside a given
directory. It returns the result in an array.
function retrieveDirs($rootdirpath) {
if ($dir = @opendir($rootdirpath)) {
$array[] = $rootdirpath;
while (($file = readdir($dir)) !== false) {
if (is_dir($rootdirpath."/".$file) && $file != "." &&
$file != "..") {
$array = array_merge($array, retrieveDirs($rootdirpath."/".$file));
}
}
closedir($dir);
}
return $array;
}