Re: sorting readdir output? [message #184002 is a reply to message #183997] |
Sun, 01 December 2013 17:59 |
Lew Pitcher
Messages: 60 Registered: April 2013
Karma:
|
Member |
|
|
On Sunday 01 December 2013 11:39, in comp.lang.php, "richard"
<noreply(at)example(dot)com> wrote:
> <?php
>
> 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<br>";
> }
>
> closedir($handle);
> }
> ?>
>
> This gives the output in an unsorted list.
> How can I make it so the array is sorted?
Sort it, of course.
As you read the directory, put each entry into the same array.
Once you've hit the end, sort the array.
--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request
|
|
|