$files = new DirectoryIterator($path);
$i = 0;
$paths = array();
while($files->valid()) {
$paths[$i++] = $files->getFileName();
$files->next();
}
sort($paths)
May be what you are looking for, you can always of course apply the sort function to sort the paths depending on your preference after that.