Afficher un message
Vieux 15/09/2007, 17h03   #2
Andy Hassall
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: readdir() doesn't maintain order

On Sat, 15 Sep 2007 08:10:46 -0700, Semi Confused <PostInGroups@wherever.com>
wrote:

>$dir = opendir("thumbs");
>//read files in the dir
>while (($file = readdir($dir)) !== false)
>
>Was reviewing a few of the pages I made and something seemed odd.
>Further investigation showed that my thumbs are not in the order of the
>filesystem.
>
>So it starts at pic 1370 and ends back at 1359. In reality the pics
>start at 1359 and end at 1424. Maybe the question is how is the file
>system really sorted?


Yes.

>I haven't tried to implement the other methods shown this week and
>maybe one doesn't do this?
>or
>Readdir into an array?


Yes, or scandir() (which gives a sorted array), or glob() (which both filters
and sorts), but in either case you may still want a different sort order - in
particular look at natsort().

http://php.net/scandir
http://php.net/glob
http://php.net/natsort

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
  Réponse avec citation
 
Page generated in 0,85335 seconds with 9 queries