RE: readdir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



According to php.net, the readdir() function simply reads the contents of
the directory in the order which they are stored by the filesystem.

One way to force the order would be to loop through the contents of the
directory and store the directory names into an array, and use the functions
filemtime() and sort() to sort the array.

Hope that helps,

Brad

-----Original Message-----
From: Toby Osbourn [mailto:toby.osbourn@xxxxxxxxxxxxxx] 
Sent: Friday, September 15, 2006 3:18 PM
To: php-general@xxxxxxxxxxxxx
Subject:  readdir

I have been writing some code that visits each directory stored within one
directory in turn, pics a random image from it and displays that image.

I have the code working fine, apart from one small quirk that I can't really
understand.

In one version of the implementation, the directories appear to be getting
accessed in the order they are uploaded to / edited on the server starting
with the most recent upload/change - which is handy because it is what I
wanted.

But in another slightly different version of the same bit of code, it lists
them in some weird order that I can't fathom.

I suppose my question put simply is, what is the default ordering of
directories when PHP uses the readdir method? And is there anyway to force a
specific ordering to the directories before PHP searches down them?

Any help would be greatly appreciated.

Regards,

Toby

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux