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

Home » Imported messages » comp.lang.php » readdir lists randomly
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: readdir lists randomly [message #185201 is a reply to message #185200] Sat, 08 March 2014 15:48 Go to previous messageGo to previous message
Lew Pitcher is currently offline  Lew Pitcher
Messages: 60
Registered: April 2013
Karma:
Member
On Saturday 08 March 2014 10:15, in comp.lang.php, "Lew Pitcher"
<lew(dot)pitcher(at)digitalfreehold(dot)ca> wrote:

> On Saturday 08 March 2014 10:01, in comp.lang.php, "richard"
> <noreply(at)example(dot)com> wrote:
>
>> From the php manual
>>
>>
>> if ($handle = opendir('audio/1960')) {
>> echo "Directory handle: $handle\n";
>> echo "Entries:\n";
>>
>> /* This is the correct way to loop over the directory. */
>> while (false !== ($entry = readdir($handle))) {
>> echo "$entry\n";
>> echo "<br>";
>>
>> }
>>
>> closedir($handle);
>> }
>>
>> Is there a way to list the entries according to the order they are listed
>> in the directory?
>
> Yes, use readdir(). readdir() reads directory entries in the same order as
> they exist in the directory.
>
>> such as
>> 60-001
>> 60-002
>> 60-003
>
> Oh, you mean in a specific *sorted* order, and not by the order that the
> directory entries are recorded.
>
> For that, you are going to have to read the directory and sort it.

And, for that, you could use scandir()
See http://ca3.php.net/manual/en/function.scandir.php

--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [CM] Falkvinge: MtGox had custom SSHD written in PHP
Next Topic: Filling an array with random input doesn't quite work
Goto Forum:
  

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

Current Time: Sun Nov 24 23:30:41 GMT 2024

Total time taken to generate the page: 0.04216 seconds