[ACCEPTED]-PHP readdir() not returning files in alphabetical order-php
Alphabetical order :: I think you misread 10 the snippet you quoted...
Returns the filename 9 of the next file from the directory. The 8 filenames are returned in the order in which 7 they are stored by the filesystem.
The fact 6 that 'ls' would display the files in (usually) alphabetical 5 order does not mean that's how they are 4 stored on the filesystem. PHP is behaving 3 as spec, I'm afraid.
You may want to consider 2 using scandir as the basis for your efforts, if 1 alphabetical sorting is a must. :)
You could copy all the filenames into an 1 array and then use
<?php sort($filesArray); ?>
i suppose docs are quite clear here.
order 2 in which they are stored in filesystem
is 1 not the same as alphabetic order
You're misreading the docs:
The filenames 4 are returned in the order in which they 3 are stored by the filesystem.
means that 2 files are returned in the order they were 1 created.
More Related questions