It does not read it in reverse alphabetical order, but in the order it is listed on the filesystem, which happens to be in reverse alphabetical order. If you need it ordered, use

$files=array();
if (!($dp = opendir($default_dir))) die("cannot open $default_dir");
while($file = readdir($dp))
if($file != '.' && $file != '..') $files[]=$file;
closedir($dp);

sort($files);
foreach($files as $file) {
echo"<a href='opendir.php?opendir=$file'>$file</a><BR>";
}



Bob Irwin wrote:

Hi Guys,

Does anyone happen to know why the below code reads the directory in reverse
alphabetical order? Not a major problem - easy enough to whack it in an
array and sort it, but annoying nonetheless.


$default_dir = "../screenshots";

if (!($dp = opendir($default_dir))) die("cannot open $default_dir");
while($file = readdir($dp))
if($file != '.' && $file != '..') echo"<a
href='opendir.php?opendir=$file'>$file</a><BR>";
closedir($dp);

Best Regards
Bob Irwin
Server Admin & Web Programmer
Planet Netcom




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to