Re: re-ordering keys in an array
| From: | Jason k Larson | Date: | Tue, 21 Jan 2003 14:15:48 +0000 |
| Subject: | Re: re-ordering keys in an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-132401@lists.php.net to get a copy of this message | ||
There are many pre-defined functions to manipulate the sort order of arrays and it's keys. However sometimes, to fit special needs, you just have to do it manually. Here's the useful PHP reference manual links to better understand what's available.
http://www.php.net/manual/en/ref.array.php
http://www.php.net/manual/en/function.asort.php
http://www.php.net/manual/en/function.arsort.php
http://www.php.net/manual/en/function.ksort.php
http://www.php.net/manual/en/function.krsort.php
http://www.php.net/manual/en/function.usort.php
http://www.php.net/manual/en/function.uksort.php
HTH,
Jason k Larson
David T-G wrote:
Hi, all -- If I have an associative array $a like Array ([t] => temp1 [u] => ugh [m] => moo) is there any way to re-order the keys so that foreach (array_keys($a) as $k){ print "$k\n" ; }will print t m u for me? At the moment it seems my only option is sort(array_keys($a)) and that's a start but finding another order spec would be lovely... TIA & HAND :-D