“Matriz multidimensional de classificação PHP” Respostas de código

Matriz multidimensional de classificação PHP

function sortByAge($a, $b) {
    return $a['age'] > $b['age'];
}
$people=[
    ["age"=>54,"first_name"=>"Bob","last_name"=>"Dillion"],
    ["age"=>22,"first_name"=>"Sarah","last_name"=>"Harvard"],
    ["age"=>31,"first_name"=>"Chuck","last_name"=>"Bartowski"]
];

usort($people, 'sortByAge'); //$people is now sorted by age (ascending)
Grepper

Matriz multidimensional de classificação PHP

array_multisort(array_map(function($element) {
      return $element['order'];
  }, $array), SORT_ASC, $array);

print_r($array);
Thoughtless Turkey

Matriz multidimensional de classificação PHP

usort($myArray, function($a, $b) {
    return $a['order'] <=> $b['order'];
});
RapTToR

Respostas semelhantes a “Matriz multidimensional de classificação PHP”

Perguntas semelhantes a “Matriz multidimensional de classificação PHP”

Mais respostas relacionadas para “Matriz multidimensional de classificação PHP” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código