Tuesday 15 February 2011

PHP (WAMP) not sorting files the same way as Windows -


To use WAMP, I am trying to sort the PHP as the Windows using the following code:

& lt ;? Php $ folder = opendir ("folderx"); $ FileNameList = Array (); While (wrong! == ($ fileName = readdir ($ folder))) {array_push ($ fileNameList, $ fileName); } Echo "prefix"; Print_r ($ fileNameList); Echo "& lt; / pre & gt;"; ? & Gt;

However, I'm getting strange results on how PHP is sorting:

  array ([ 0] = & gt ;. [1] = & gt ;. [2] = & gt; New Text Document - Copy (2) - Copy - Copy.txt [3] = & gt; New Text Document - Copy ( 2) - Copy.txt [4] = & gt; New Text Document - Copy (2) .txt [5] = & New Text Document - Copy (3) - Copy.txt [6] = & gt; New Text Document - Copy (3) .txt [7] = & gt; New Text Document - Copy (4) - Copy.txt [8] => New Text Document - Copy (4) .txt [9] = & New text slip Waze - Copy - Copy (2) - Copy.txt [10] = & gt; New Text Document - Copy - Copy (2) .txt [11] = & gt; New Text Document - Copy - Copy (3). Txt [12] = & gt; new text document - copy - copy - copy (2) .txt [13] = & gt; new text document - copy - per-copy - copy = txt [14] => new Text document - copy - copy - copy.txt [15] = & gt; new text document - copy - copy.txt [16] = & gt; new text document - copy.txt [17] = & gt; New text document. Txt)   

and how is this sorting Windows:

Enter image details here

How about if you sort the array Natcasesort ( $ FileNameList) Use this as:

  ";    

No comments:

Post a Comment