Sort Matrix by Name In PHP

$data = array(    array("firstname" => "Mary", "lastname" => "Johnson", "age" => 25),    array("firstname" => "Amanda", "lastname" => "Miller", "age" => 18),    array("firstname" => "James", "lastname" => "Brown", "age" => 31),    array("firstname" => "Patricia", "lastname" => "Williams", "age" => 7),    array("firstname" => "Michael", "lastname" => "Davis", "age" => 43),    array("firstname" => "Sarah", "lastname" => "Miller", "age" => 24),    array("firstname" => "Patrick", "lastname" => "Miller", "age" => 27)  );function compare_row($a, $b){  return strnatcmp($a['lastname'], $b['lastname']);}// sort alphabetically by nameusort($data , 'compare_row');

Anuncis

Etiquetes: , ,

Deixa un comentari

Fill in your details below or click an icon to log in:

WordPress.com Logo

Esteu comentant fent servir el compte WordPress.com. Log Out / Canvia )

Twitter picture

Esteu comentant fent servir el compte Twitter. Log Out / Canvia )

Facebook photo

Esteu comentant fent servir el compte Facebook. Log Out / Canvia )

Google+ photo

Esteu comentant fent servir el compte Google+. Log Out / Canvia )

Connecting to %s


%d bloggers like this: