Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #12056
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: sorting readdir output? |
| Date | 2013-12-01 18:10 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <l7fu22$qqd$1@dont-email.me> (permalink) |
| References | <1g1k8whk9o5qm.19jj117exjuzm.dlg@40tude.net> <vOKmu.376035$jg4.217970@fx05.iad> |
"Lew Pitcher" <lew.pitcher@digitalfreehold.ca> wrote in message
news:vOKmu.376035$jg4.217970@fx05.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
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
sorting readdir output? richard <noreply@example.com> - 2013-12-01 11:39 -0500
Re: sorting readdir output? Norman Peelman <npeelman@cfl.rr.com> - 2013-12-01 11:56 -0500
Re: sorting readdir output? richard <noreply@example.com> - 2013-12-01 12:13 -0500
Re: sorting readdir output? Luuk <luuk@invalid.lan> - 2013-12-01 18:32 +0100
Re: sorting readdir output? Luuk <luuk@invalid.lan> - 2013-12-01 18:35 +0100
Re: sorting readdir output? richard <noreply@example.com> - 2013-12-01 13:10 -0500
Re: sorting readdir output? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2013-12-01 13:19 -0500
Re: sorting readdir output? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2013-12-01 12:59 -0500
Re: sorting readdir output? "James Harris" <james.harris.1@gmail.com> - 2013-12-01 18:10 +0000
Re: sorting readdir output? richard <noreply@example.com> - 2013-12-01 13:19 -0500
Re: sorting readdir output? Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-01 23:41 +0000
Re: sorting readdir output? Richard Yates <richard@yatesguitar.com> - 2013-12-02 10:54 -0800
Re: sorting readdir output? Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-02 20:24 +0000
Re: sorting readdir output? Richard Yates <richard@yatesguitar.com> - 2013-12-02 13:02 -0800
Re: sorting readdir output? Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-02 22:33 +0100
Re: sorting readdir output? Tim Streater <timstreater@greenbee.net> - 2013-12-02 22:20 +0000
Re: sorting readdir output? Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-02 23:54 +0000
csiph-web