ordenar array php multidimensional code example

Example: php sort multidimensional array

$inventory = array(
   array("type"=>"Fruit", "price"=>3.50),
   array("type"=>"milk", "price"=>2.90),
   array("type"=>"Pork", "price"=>5.43),
);

$prices = array_column($inventory, 'price');
$inventory_prices = array_multisort($prices, SORT_DESC, $inventory);

$types = array_map(strtolower, array_column($inventory, 'type'));
$inventory_types = array_multisort($types, SORT_ASC, $inventory);

Tags:

Php Example