RE: [PHP] Sorting Multidimensional Arrays
| From: | Jack Dempsey | Date: | Mon, 07 May 2001 17:30:28 +0000 |
| Subject: | RE: [PHP] Sorting Multidimensional Arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-51781@lists.php.net to get a copy of this message | ||
check http://www.php.net/manual/en/function.asort.php
there's a routine someone wrote in the contributed section...
-jack
-----Original Message-----
From: Rick Dietz [mailto:rbdietz@indiana.edu]
Sent: Monday, May 07, 2001 1:21 PM
To: php-general@lists.php.net
Subject: [PHP] Sorting Multidimensional Arrays
I'm having trouble finding a function to sort a multidimensional array by
the value of a given key in the contained arrays. Perhaps i'm missing
something, perhaps PHP is missing something.
Take the array below. All I'm looking to do is reorder $my_array based on
the value of the "name" key for example--to order $my_array based on the
alphabetical order of the "names".
$my_array = array (
array ("name"=>"Sam", "age"=>"20",
married="yes"),
array ("name"=>"Alice",
"age"=>"25", married="no"),
array ("name"=>"Jim", "age"=>"19",
married="no"),
array ("name"=>"Janice",
"age"=>"22", married="yes")
);
Am I missing something that already exists?
-Rick
--
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