note 36471 added to ref.dir
| From: | php-general at lists dot php dot net | Date: | Fri, 10 Oct 2003 19:12:06 +0000 |
| Subject: | note 36471 added to ref.dir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-58207@lists.php.net to get a copy of this message | ||
get a list of files and directories recursivelly without the use of global variables.
the difference between this one and piccaso at gmx dot net's, is that this one returns files
inside the subdirectories as well (with full path) :
function recursive_listdir($base) {
static $filelist = array();
static $dirlist = array();
if(is_dir($base)) {
$dh = opendir($base);
while (false !== ($dir = readdir($dh))) {
if (is_dir($base ."/". $dir) && $dir !== '.' && $dir
!== '..') {
$subbase = $base ."/". $dir;
$dirlist[] = $subbase;
$subdirlist = recursive_listdir($subbase);
} elseif(is_file($base ."/". $dir) && $dir !== '.'
&& $dir !== '..') {
$filelist[] = $base ."/". $dir;
}
}
closedir($dh);
}
$array['dirs'] = $dirlist;
$array['files'] = $filelist;
return $array;
}
----
Manual Page -- http://www.php.net/manual/en/ref.dir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36471
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36471&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36471&report=yes
Search -- http://master.php.net/manage/user-notes.php