note 37810 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 19:05:57 +0000
Subject: note 37810 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126546@lists.php.net to get a copy of this message
Note Submitter: rockinmusicgv at y_NOSPAM_ahoo dot com ---- Mainly an extension of the other drop down directory lists Except it should handle hidden directories (unix) function getdirs($directory, $select_name, $selected = "") { if ($dir = @opendir($directory)) { while (($file = readdir($dir)) !== false) { if ($file != ".." && $file != ".") { if(is_dir($file)) { if(!($file[0] == '.')) { $filelist[] = $file; } } } } closedir($dir); } echo "<select name=\"$select_name\">"; asort($filelist); while (list ($key, $val) = each ($filelist)) { echo "<option value=\"$val\""; if ($selected == $val) { echo " selected"; } echo ">$val</option>"; } echo "</select>"; }

« previous php.notes (#126546) next »