note 23404 added to function.is-dir
| From: | james dot elkins at usinfotel dot com | Date: | Wed, 17 Jul 2002 17:05:54 +0000 |
| Subject: | note 23404 added to function.is-dir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33215@lists.php.net to get a copy of this message | ||
More details about my previous post...
PHP 4.1.2
Apache 1.3.23
Red Hat Linux 7.3
This code will list all files in a directory whether they are directories or regular files. It
*should* omit directories and show only regular files:
$dir = opendir("/home/username/public_html/some_directory");
while (($file = readdir($dir)) !== false) {
if (!is_dir($file)) {
echo "<option
value=\"".$file."\">".$file."</option>";
}
}
closedir($dir);
I tried the following workaround with the same results:
$dir = opendir("/home/username/public_html/some_directory");
while (($file = readdir($dir)) !== false) {
if (is_file($file)) {
echo "<option
value=\"".$file."\">".$file."</option>";
}
}
closedir($dir);
Is this a bug, or am I not using the functions correctly in the above examples?
--
http://www.php.net/manual/en/function.is-dir.php
http://master.php.net/manage/user-notes.php?action=edit+23404
http://master.php.net/manage/user-notes.php?action=delete+23404
http://master.php.net/manage/user-notes.php?action=reject+23404