Re: array order
| From: | jeremy brand | Date: | Fri, 29 Sep 2000 07:22:01 +0000 |
| Subject: | Re: array order | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-18006@lists.php.net to get a copy of this message | ||
try some of the array sorting functions:
asort() or ksort() (or the reverse functions as well).
http://www.php.net/manual/function.asort.php
http://www.php.net/manual/function.ksort.php
-jeremy brand
_______________________________________________________________________
GnuPG Fingerprint: 9F5E 95E0 1CC2 E054 84EA 6099 8ACD 9DBA D2C0 5EA9
_ http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html
for more __
_ http://www.google.com/search?q=jeremy+brand
__
On Thu, 28 Sep 2000, Theodore Jones wrote:
> Date: Thu, 28 Sep 2000 21:35:56 -0700
> From: Theodore Jones <theoj@transport.com>
> To: PHP List <php-general@lists.php.net>
> Subject: [PHP] array order
>
> Hello All,
>
> I have a script that iterates through a series of directories as such:
>
> 01-07-2000
> 01-14-2000
> 02-08-2000
> 02-16-2000
> 02-23-2000
> 03-09-2000
> 03-24-2000
> 04-07-2000
> 04-21-2000
> 07-15-2000
> 07-22-2000
> 09-14-2000
>
> (directory named by date)
>
> when I read all these directories in with an opendir() function and feed them
> into an array,
> my display order seems to follow no logical order when the page comes out. For
> example I would like the "latest" (09-14-2000) directory uploaded to show up at
> the top of the list, and the "oldest" 01-07-2000 directory to appear at the
> bottom of the list. Instead they display in no logical order...?
>
> Here's the portion of code I'm working with:
>
> $thumb_dir_handle = opendir($thumb_dir);
> $a = 0;
> while($file = readdir($thumb_dir_handle)) {
> if((preg_match('/jpg/',$file)) ||
> (preg_match('/png/',$file)) ||
> (preg_match('/gif/',$file)) ||
> (preg_match('/jpeg/',$file))) {
> $file_array[$a] = $file;
> $a++;
> $file_count = count ($file_array);
> }
> }
>
> ... any ideas most greatfully solicited...
>
> Thanks,
>
> ~ Theo
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>