Actionscript and php question

My actionscript file is reading an image folder via a php script. Does anyone know which order the script reads the files in. Currently it doesn’t necessarily read them in alphabetical order, nor in date order. In fact, I can’t see any logical order when I print out the files it has read.
Here’s the script (any insight would be graetly welcomed):

<?php

$filepath = “thumbs”;

$handle = opendir($filepath);
while (false != ($file = readdir($handle))) {
if ($file != “.” && $file != “…” && $file != “.DS_Store” && $file != “index.html” && $file != “index.htm” && $file != “index.php”) {
if ($output) $output .= “|”;
$output .= “$file”;
}
}

closedir($handle);
echo “&files=$output&”;

?>