Re: Sort Array

From: Date: Tue, 18 Jul 2006 14:38:59 +0000
Subject: Re: Sort Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-239547@lists.php.net to get a copy of this message
ksort won't do what he wants... Look at usort, and something like this: function cmp($a, $b) { return strcmp($a['Country'], $b['Country']); } usort($array, "cmp"); Andrew ----- Original Message ----- From: "Jay Blanchard" <jblanchard@pocket.com> To: "weetat" <weetat.yeo@cxrus.com>; <php-general@lists.php.net> Sent: Tuesday, July 18, 2006 3:17 PM Subject: RE: [PHP] Sort Array [snip] I have the array below : How to sort the array by "Model" and "Country? Thanks array( "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"), "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"), "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"), "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"), "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"), ) [/snip] http://www.php.net/manual/en/function.ksort.php

« previous php.general (#239547) next »