FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » sorting readdir output?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: sorting readdir output? [message #184003 is a reply to message #184002] Sun, 01 December 2013 18:10 Go to previous messageGo to previous message
James Harris is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: dropdown menus
Next Topic: Re: SEO SERVICES
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 05:39:05 GMT 2024

Total time taken to generate the page: 0.20696 seconds