note 32246 deleted from ref.dir by sniper
| From: | sniper@php.net | Date: | Thu, 15 Dec 2005 23:59:52 +0000 |
| Subject: | note 32246 deleted from ref.dir by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100251@lists.php.net to get a copy of this message | ||
Note Submitter: fabrizio - > effepi.system at inwind.it
----
here a function that create an array with all the files and
folders in the directory and in all the subdirectories
qui una funzione che crea un array con tutti i file e le cartelle
nella directory ricercata e nelle sue subdirectories
i.e.:
dir1
|-dir2
| |-file1
| |-dir3
|-file2
$array[dir1][dir2][0] = file1
$array[dir1][dir2][dir3]=NULL //no files inside
$array[dir1][0] = file2
function expFp($folder = ".", $filetype = "")
{
$currdir=getcwd();
if ($folder)
@chdir("$folder");
$dh = opendir(".");
while(false !== ($file = readdir($dh)))
{
// insert all the files in an array
if(is_file($file) &&
( strtoupper( substr( $file,(-1*strlen($filetype))))==strtoupper($filetype)))
$a_files[] = $file;
//htm is a folder that you don't want to use
if (is_dir($file) && $file!="." && $file!=".."
&& $file!="htm")
$a_files[$file] = expFp($file, $filetype);
}
closedir($dh);
chdir($currdir);
// if (is_array($a_files))
// array_multisort($a_files);
return $a_files;
}