Re: Array sorting by key?
| From: | Andrei Zmievski | Date: | Fri, 14 Jul 2000 13:07:28 +0000 |
| Subject: | Re: Array sorting by key? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-24525@lists.php.net to get a copy of this message | ||
On Fri, 14 Jul 2000, John Parker wrote:
> Hmm.. I might just be having one of those days, but...
>
> If I had an array in a loop as such...
>
> $ourArray[type][$loop] = "a";
> $ourArray[name][$loop] = "whatever"
>
> Is there any means of sorting the array by a specific key (such as 'name')
> using the PHP array sort functions, or do I have to resort to using a user
> defined sort function in conjunction with uasort?
>
> If I'm just being thick feel free to let me know. Otherwise, any help would
> be appreciated.
array_multisort($ourArray[name], $ourArray[type]);
See array_multisort() docs when they are posted.
-Andrei
"When I get a little money, I buy books;
and if any is left I buy food and clothes." -- Erasmus