note 77311 deleted from function.opendir by nlopess

From: Date: Sat, 01 Sep 2007 16:23:57 +0000
Subject: note 77311 deleted from function.opendir by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-130036@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. 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 $files = arrayDir(getcwd().'/'); Michael http://codefisher.org/

« previous php.notes (#130036) next »