I am reading through a directory with some pictures and such using a pretty simple implementation of readdir() like the following:
if ($handle = opendir($pat
i suppose docs are quite clear here.
order in which they are stored in filesystem
is not the same as alphabetic order
Alphabetical order :: I think you misread the snippet you quoted...
Returns the filename of the next file from the directory. The filenames are returned in the order in which they are stored by the filesystem.
The fact that 'ls' would display the files in (usually) alphabetical order does not mean that's how they are stored on the filesystem. PHP is behaving as spec, I'm afraid.
You may want to consider using scandir as the basis for your efforts, if alphabetical sorting is a must. :)
There are a couple you can use:
Alphabetical Sort:
<?php
sort($handle);
?>
Reverse Alphabetical Sort:
<?php
rsort($handle);
?>
You could copy all the filenames into an array and then use
<?php
sort($filesArray);
?>
You're misreading the docs:
The filenames are returned in the order in which they are stored by the filesystem.
means that files are returned in the order they were created.