note 34448 deleted from function.is-dir by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:34:55 +0000 |
| Subject: | note 34448 deleted from function.is-dir by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58445@lists.php.net to get a copy of this message | ||
Note Submitter: miked@droplab.com
----
This is based on bigi at agum dot com's recursive dir function. This version creates a
multidimensional associative array of all files in a directory.
function retrieveDirs($path)
{
$delim = "\\"; // Change to "/" for unix
if($dir=@opendir($path))
{
$key = strrchr($path,$delim);
$key = substr($key,1,strlen($key));
while(($file=readdir($dir))!== false)
{
if(is_dir($path.$delim.$file) AND $file!= "." AND $file!= "..")
{
$array[$file] = retrieveDirs($path.$delim.$file);
}
elseif($file!= "." AND $file!= "..")
{
$array[] = $file;
}
}
closedir($dir);
}
return $array;
}