note 70091 added to function.readdir
| From: | Cynagencynagen | Date: | Mon, 02 Oct 2006 21:41:51 +0000 |
| Subject: | note 70091 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117968@lists.php.net to get a copy of this message | ||
I have recently created a function I have called filearray, which makes use of opendir(), readdir(),
and closedir(), to create and output a recursive array in which all files and folders underneath the
target main folder ( / = default) that you can parse how you want, array_search it or whatever you
need to do. Search 1 or more directories automatically recursively with this.
function filearray($start="/") {
$dir=opendir($start);
while (false !== ($found=readdir($dir))) { $getit[]=$found; }
foreach($getit as $num => $item) {
if (is_dir($start.$item) && $item!="." && $item!="..") {
$output["{$item}"]=filearray($start.$item."/"); }
if (is_file($start.$item)) { $output["{$item}"]="FILE"; }
}
closedir($dir);
return $output;
}
----
Server IP: 64.71.164.2
Probable Submitter: 72.165.21.65
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- https://master.php.net/note/edit/70091
Del: integrated -- https://master.php.net/note/delete/70091/integrated
Del: useless -- https://master.php.net/note/delete/70091/useless
Del: bad code -- https://master.php.net/note/delete/70091/bad+code
Del: spam -- https://master.php.net/note/delete/70091/spam
Del: non-english -- https://master.php.net/note/delete/70091/non-english
Del: in docs -- https://master.php.net/note/delete/70091/in+docs
Del: other reasons-- https://master.php.net/note/delete/70091
Reject -- https://master.php.net/note/reject/70091
Search -- https://master.php.net/manage/user-notes.php