Re: How to sort by 3rd row in an 2d-Array
| From: | Andrey Hristov | Date: | Mon, 15 Apr 2002 12:55:10 +0000 |
| Subject: | Re: How to sort by 3rd row in an 2d-Array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92988@lists.php.net to get a copy of this message | ||
usort() /uksort()/uasort()
look here :
http://www.php.net/manual/en/function.uasort.php
There is an example in the user notes.
Andrey
----- Original Message -----
From: "SED" <sed@sed.is>
To: <php-general@lists.php.net>
Sent: Friday, April 12, 2002 7:25 PM
Subject: [PHP] How to sort by 3rd row in an 2d-Array
> Hi,
>
> I'm trying to sort an array like following
>
> myArray[1][firstname] = "Joe";
> myArray[1][lastname] = "Smith";
> myArray[1][company] = "Bullock";
> myArray[1][email] = "joe@bullock.com";
> myArray[2][firstname] = "Jim";
> myArray[2][lastname] = "Cords";
> myArray[2][company] = "Jamen";
> myArray[2][email] = "234@hotmail.com";
> etc...
>
> by the company name. How can I do it?
>
> I found the solution on php.net
> (http://www.php.net/manual/en/function.array-multisort.php) but it sorts
> only the first row:
>
> foreach ($myArray as $val) {
> $sortarray[] = $val['nafn'];
> echo $val['stadur'];
> }
> array_multisort($myArray, $sortarray);
>
> Thanks in advance!
>
> SED
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>