Re: sorting readdir output? [message #184003 is a reply to message #184002] |
Sun, 01 December 2013 18:10 |
James Harris
Messages: 11 Registered: November 2013
Karma:
|
Junior Member |
|
|
"Lew Pitcher" <lew(dot)pitcher(at)digitalfreehold(dot)ca> wrote in message
news:vOKmu(dot)376035$jg4(dot)217970(at)fx05(dot)iad...
....
>> if ($handle = opendir('../audio/1960/')) {
....
>> while (false !== ($entry = readdir($handle))) {
>> echo "$entry\n<br>";
>> }
....
>> This gives the output in an unsorted list.
>> How can I make it so the array is sorted?
....
> As you read the directory, put each entry into the same array.
> Once you've hit the end, sort the array.
How about using scandir?
$ents = scandir($document_root . $dir);
natcasesort($ents);
James
|
|
|