note 36405 deleted from ref.dir by sniper
| From: | sniper@php.net | Date: | Fri, 16 Dec 2005 00:00:08 +0000 |
| Subject: | note 36405 deleted from ref.dir by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100255@lists.php.net to get a copy of this message | ||
Note Submitter: arun at upress dot unm dot edu
----
correction to piccaso at gmx dot net's
function recrusive_dirlist($base_dir)
<?
/*
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
!== '..') //note the change in this line
{
$subs = $dir ;
$subbase = $base ."/". $dir;//note the change in this line
$getDirList_alldirs[]=$subbase;
getDirList($subbase);
}
elseif(is_file($base ."/". $dir) && $dir !== '.' &&
$dir !== '..')//change in this line too
{
$getDirList_allfiles[]=$base ."/". $dir;//change in this line too
}
}
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
*/
?>
I used the function without making any changes and did not get any output, no error though. then i
realised the mistake and did the changes and got perfect output.
hope this helps someone in future.
Arun.