skip certain file in readdir();
Posted: Sun Jan 25, 2004 7:16 pm
got this readdir() function:
but i need to skip one file within this dir (file.php) so that it's not returned to the select field...
anyone?
thanks
glenn
Code: Select all
function listfiles($directory, $select_name, $selected = "") {
if ($dir = @opendir("/home/ensign/public_html/prose")) {
while (($file = readdir($dir)) !== false) {
if ($file != ".." && $file != ".") {
$filelistї] = $file;
}
}
closedir($dir);
}
echo "<select name="filename">";
asort($filelist);
while (list ($key, $val) = each ($filelist)) {
echo "<option value="$val"";
if ($selected == $val) {
echo "selected";
}
echo ">$val</option>";
}
echo "</select>";
}
listfiles ($key, $val);anyone?
thanks
glenn