...

View Full Version : Sorting a 2 dimentional array



markhartnady
03-22-2004, 10:47 AM
I have a 2 dimentional array called $country_list with "url" and "name" as keys:

Ie:

country_list[0]["url"] = "xxx"
country_list[0]["name"] = "aaa"

country_list[1]["url"] = "yyy"
country_list[1]["name"] = "bbb"

country_list[2]["url"] = "zzz"
country_list[2]["name"] = "ccc"

How do I sort the array by the name key?

raf
03-22-2004, 12:28 PM
http://www.php.net/manual/en/function.array-multisort.php

markhartnady
03-22-2004, 12:32 PM
Thanks, but after more analysis, I discovered the array actually looks like this: (slighty more complicated).

Array ( [0] => stdClass Object ( [url_trademap] => http://www.trademap.net/benin/connection.htm [country] => Benin ) [1] => stdClass Object ( [url_trademap] => http://www.trademap.net/bolivia/conexion.htm [country] => Bolivia ) [2] => stdClass Object ( [url_trademap] => http://www.trademap.net/burkina/connection.htm [country] => Burkina Faso ) [3] => stdClass Object ( [url_trademap] => http://www.trademap.net/prochile/conexion.htm [country] => Chile ) [4] => stdClass Object ( [url_trademap] => http://www.trademap.net/china/login.htm [country] => China )

etc. etc.

I tried multisort, but that didn't work. I actually need to specify the "country" key (inside the object) somewhere or somehow.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum