PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
glennn3
Forum Commoner
Posts: 63 Joined: Sat Sep 20, 2003 8:43 pm
Post
by glennn3 » Sun Jan 25, 2004 7:16 pm
got this readdir() function:
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);
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
DuFF
Forum Contributor
Posts: 495 Joined: Tue Jun 24, 2003 7:49 pm
Location: USA
Post
by DuFF » Sun Jan 25, 2004 9:53 pm
Easy:
Code: Select all
<?php
if ($file != ".." && $file != "." && $file != "filename.php") {
$filelist[] = $file;
}
?>
Just replace "filename.php" with whatever file you don't want to include.
glennn3
Forum Commoner
Posts: 63 Joined: Sat Sep 20, 2003 8:43 pm
Post
by glennn3 » Sun Jan 25, 2004 10:01 pm
thanks, duff - you're the man.
g