Using WAMP, I'm trying to make PHP sort the same way as Windows using the following code:
<?php
$folder = opendir("folderx");
$fileNameList = array();
while(false !== ($fileName = readdir($folder))){
array_push($fileNameList, $fileName);
}
echo "<pre>";
print_r($fileNameList);
echo "</pre>";
?>
However, I'm getting weird results. This is how PHP is sorting:
Array
(
[0] => .
[1] => ..
[2] => New Text Document - Copy (2) - Copy - Copy.txt
[3] => New Text Document - Copy (2) - Copy.txt
[4] => New Text Document - Copy (2).txt
[5] => New Text Document - Copy (3) - Copy.txt
[6] => New Text Document - Copy (3).txt
[7] => New Text Document - Copy (4) - Copy.txt
[8] => New Text Document - Copy (4).txt
[9] => New Text Document - Copy - Copy (2) - Copy.txt
[10] => New Text Document - Copy - Copy (2).txt
[11] => New Text Document - Copy - Copy (3).txt
[12] => New Text Document - Copy - Copy - Copy (2).txt
[13] => New Text Document - Copy - Copy - Copy - Copy.txt
[14] => New Text Document - Copy - Copy - Copy.txt
[15] => New Text Document - Copy - Copy.txt
[16] => New Text Document - Copy.txt
[17] => New Text Document.txt
)
And this is how Windows is sorting: