note 21423 added to function.readdir
| From: | Geoff at squiggle dot org | Date: | Sun, 12 May 2002 19:34:22 +0000 |
| Subject: | note 21423 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30556@lists.php.net to get a copy of this message | ||
Files are returned in the order that they are on the filesystem. This piece of code will list all
files apart from index.php in the current directory:
$filelist = array();
$handle = opendir('.');
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file !=
"index.php") {
array_push($filelist, " <a
href=\"$file\">$file</a><br>\n");
}
}
closedir($handle);
asort ($filelist);
reset ($filelist);
while (list ($key, $val) = each ($filelist)) { echo "$val"; }
--
http://www.php.net/manual/en/function.readdir.php
http://master.php.net/manage/user-notes.php?action=edit+21423
http://master.php.net/manage/user-notes.php?action=delete+21423
http://master.php.net/manage/user-notes.php?action=reject+21423