Re: Sort Array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
To: "weetat" <weetat.yeo@xxxxxxxxx>; <php-general@xxxxxxxxxxxxx>
Sent: Tuesday, July 18, 2006 3:17 PM
Subject: RE:  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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux