note 34448 added to function.is-dir
| From: | miked at droplab dot com | Date: | Mon, 28 Jul 2003 07:00:59 +0000 |
| Subject: | note 34448 added to function.is-dir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52812@lists.php.net to get a copy of this message | ||
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;
}
----
Manual Page -- http://www.php.net/manual/en/function.is-dir.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34448
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34448&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34448&report=yes