note 35600 added to ref.dir

From: Date: Mon, 08 Sep 2003 04:17:39 +0000
Subject: note 35600 added to ref.dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-55773@lists.php.net to get a copy of this message
<? /* 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 */ ?> ---- Manual Page -- http://www.php.net/manual/en/ref.dir.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35600 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35600&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35600&report=yes

« previous php.notes (#55773) next »