$student_data = array(
array(
"id" => 1,
"student_name" => "Kasimir Clark",
"country" => "Chile"
),
array(
"id" => 2,
"student_name" => "Kyle Myers",
"country" => "Cook Islands"
),
array(
"id" => 3,
"student_name" => "Merrill Velez",
"country" => "Israel"
),
array(
"id" => 4,
"student_name" => "Kadeem Graham",
"country" => "Christmas Island"
),
);
usort($student_data, function($a, $b)
{
return $a["student_name"] - $b["student_name"];
});
I need to sort the multi-dimentional array in PHP. Is it possible to sort the country then by the name? I tried to achieve in usort but I can only sort by one condition such as either name or country.
I would like to achieve something like what MySQL database is doing. Something like
SELECT * FROM STUDENT order by country,name
Thank you for your help.