note 77312 deleted from function.opendir by nlopess
| From: | nlopess@php.net | Date: | Sat, 01 Sep 2007 16:24:01 +0000 |
| Subject: | note 77312 deleted from function.opendir by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-130037@lists.php.net to get a copy of this message | ||
Note Submitter: admin at codefisher dot org
----
This is my little version of the get subfiles function. It returns and array of all the files in
the folder and all subfolders. I than can manipulate it as needed.
<?php
function arrayDir($folder){
$files = array();
if ($handle = opendir($folder)) {
while (false !== ($dir = readdir($handle))) {
if ($dir != "." && $dir != "..") {
if(is_dir($folder.$dir.'/')) {
$files = array_merge($files,arrayDir($folder.$dir.'/'));
} else {
$files[] = $folder.$dir;
}
}
}
closedir($handle);
}
return $files;
}
?>
I normally call it with something like
<?php $files = arrayDir(getcwd().'/'); ?>
Michael
http://codefisher.org/