Possible Duplicate:
PHP readdir() not returning files in alphabetical order
When uploaded to the hosting server, Readdir does not seem to read files alphabetically. I kinda named my files in a particular order so I really need the feature.
Here is my code:
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$ext = pathinfo($dir.$file,PATHINFO_EXTENSION);
if ($ext == 'jpg' || $ext == 'png') {
$dataArr = split('\.',$file);
$file = $dataArr[0];
?>
<li>
<a href="/test/img/picture gallery/<?php echo $folder.'/'; ?><?php echo $file; ?>.jpg">
<img src="/test/img/picture gallery/<?php echo $folder.'/thumbs/t'; ?><?php echo $fileFirst; ?>.jpg" title="" class="image0">
</a>
</li>
<?php
}
}
closedir($dh);
}
}
Any ideas on how to make this possible? Thanks!
EDIT:
Fixed.
I tried saving them into an array and using the sort() function of PHP to well, sort it alphabetically. It appears that the file system does not read files alphabetically.