note 68252 added to function.scandir
| From: | malmsteenforceattlendotpl at osu1 dot php dot net | Date: | Wed, 19 Jul 2006 19:55:27 +0000 |
| Subject: | note 68252 added to function.scandir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114947@lists.php.net to get a copy of this message | ||
This function is recursive version of scandir, it scans all directories inside given directory. For
instance : if we give path './dir1/' as argument , function will find also /dir1/dir2/file
etc. - everything what`s inside given directory.
function scandir_recursive($path)
{
if (!is_dir($path)) return 0;
$list=array();
$directory = @opendir("$path"); // @-no error display
while ($file= @readdir($directory))
{
if (($file<>".")&&($file<>".."))
{
$f=$path."/".$file;
$f=preg_replace('/(\/){2,}/','/',$f); //replace double slashes
if(is_file($f)) $list[]=$f;
if(is_dir($f))
$list = array_merge($list ,scandir_recursive($f)); //RECURSIVE CALL
}
}
@closedir($directory);
return $list ;
}
----
Server IP: 195.136.184.34
Probable Submitter: 213.134.170.155
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.scandir.php
Edit -- http://master.php.net/note/edit/68252
Del: integrated -- http://master.php.net/note/delete/68252/integrated
Del: useless -- http://master.php.net/note/delete/68252/useless
Del: bad code -- http://master.php.net/note/delete/68252/bad+code
Del: spam -- http://master.php.net/note/delete/68252/spam
Del: non-english -- http://master.php.net/note/delete/68252/non-english
Del: in docs -- http://master.php.net/note/delete/68252/in+docs
Del: other reasons-- http://master.php.net/note/delete/68252
Reject -- http://master.php.net/note/reject/68252
Search -- http://master.php.net/manage/user-notes.php