I have 3 SunOS boxes, all running the same version of OS, apache and php. I have a page on all three servers that will allow a user to select a directory from a drop down box and upon selecting the directory, be able to select a file to view from a drop down box. When the user selects the directory, the page is refreshed and a second drop down box containing the file names is displayed.
Here is where I'm running into some problems. I need the file listing to be sorted as if I were performing an 'ls -lt' listing on the server itself. I'm using the readdir() function to get the file names and load them into an array. I then walk down the array backwards to build my drop-down list. On 2 of my servers, this method works great! However, on the other one, it is throwing the most recently created files in the middle of the list. Here is the code that I'm using: $handle=opendir("$path"); while (false !== ($file = readdir($handle))) $filenames[] = $file; for($i=(count($filenames) - 1); $i >= 0; $i--) { $selected = ( $cboListFiles == $filenames[$i] ? " selected" : "" ); if ($filenames[$i] != "." and $filenames[$i] !="..") { echo "<option value=". "$filenames[$i]" . " $selected>" . "$filenames[$i]" . "</option>\n"; } } Even if I take out the sorting, the file listing order does not change. Any ideas about what may be causing this? Thanks! Joe -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php