note 70091 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 19:00:07 +0000
Subject: note 70091 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126504@lists.php.net to get a copy of this message
Note Submitter: Cynagen cynagen[(at)]gmail_dot_com ---- 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; }

« previous php.notes (#126504) next »