note 34198 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 19:06:41 +0000
Subject: note 34198 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126551@lists.php.net to get a copy of this message
Note Submitter: alfred-baudisch at bol dot com dot br ---- I use the function below in my site, is good if you wanna only images files on the filename array. function GetFileList($dirname, $extensoes = FALSE, $reverso = FALSE) { if(!$extensoes) //EXTENSIONS OF FILE YOU WANNA SEE IN THE ARRAY $extensoes = array("jpg", "png", "jpeg", "gif"); $files = array(); $dir = opendir($dirname); while(false !== ($file = readdir($dir))) { //GET THE FILES ACCORDING TO THE EXTENSIONS ON THE ARRAY for ($i = 0; $i < count($extensoes); $i++) { if (eregi("\.". $extensoes[$i] ."$", $file)) { $files[] = $file; } } } //CLOSE THE HANDLE closedir($dirname); //ORDER OF THE ARRAY if ($reverso) { rsort($files); } else { sort($files); } return $files; }

« previous php.notes (#126551) next »