Re: Reading Directory in reverse
| From: | Jim Lucas | Date: | Wed, 22 Jan 2003 23:08:00 +0000 |
| Subject: | Re: Reading Directory in reverse | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-132704@lists.php.net to get a copy of this message | ||
is it on a unix system?
if so, do an ls on the system and you will see that the files are listed in
that order.
it is the order in which they were copied to the directory.
try going through a loop before you run your main loop, create an array()
then sort that with some sorting functions and you'll have it.
Jim
----- Original Message -----
From: "Bob Irwin" <bob@staff.pnc.com.au>
To: <php-general@lists.php.net>
Sent: Wednesday, January 22, 2003 3:03 PM
Subject: [PHP] Reading Directory in reverse
> 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
>
>