note 35600 deleted from ref.dir by sniper
| From: | sniper@php.net | Date: | Fri, 16 Dec 2005 00:00:04 +0000 |
| Subject: | note 35600 deleted from ref.dir by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100254@lists.php.net to get a copy of this message | ||
Note Submitter: piccaso at gmx dot net
----
<?
/*
This function retuns all directory and file names from the given directory.
Works recrusive. Based on ltena at gmx dot net's function.
*/
function recrusive_dirlist($base_dir)
{
global $getDirList_alldirs,$getDirList_allfiles;
function getDirList($base)
{
global $getDirList_alldirs,$getDirList_allfiles;
if(is_dir($base))
{
$dh = opendir($base);
while (false !== ($dir = readdir($dh)))
{
if (is_dir($base . $dir) && $dir !== '.' && $dir !== '..')
{
$subs = $dir ;
$subbase = $base . $dir . '/';
$getDirList_alldirs[]=$subbase;
getDirList($subbase);
}
elseif(is_file($base . $dir) && $dir !== '.' && $dir !==
'..')
{
$getDirList_allfiles[]=$base . $dir;
}
}
closedir($dh);
}
}
getDirList($base_dir);
$retval['dirs']=$getDirList_alldirs;
$retval['files']=$getDirList_allfiles;
return $retval;
}
// example usage:
echo '<pre>';
print_r(recrusive_dirlist('/home/computerdreams.at/cms/'));
echo '</pre>';
/*
Prints out something like this:
Array
(
[dirs] => Array
(
[0] => /home/computerdreams.at/cms/xoops-2.0.3/
[1] => /home/computerdreams.at/cms/xoops-2.0.3/html/
[2] => /home/computerdreams.at/cms/xoops-2.0.3/html/modules/
[3] => /home/computerdreams.at/cms/xoops-2.0.3/html/modules/news/
...
...
)
[files] => Array
(
[0] => /home/computerdreams.at/cms/li
[1] => /home/computerdreams.at/cms/lo
[2] => /home/computerdreams.at/cms/tab
[3] => /home/computerdreams.at/cms/tmp
...
...
)
)
I downt know if this is the best way to do this.
If you find a better way, please drop me a note.
greez
piccaso@gmx.net
*/
?>