Answers for "array map order php"

PHP
3

sort array by key value in php

$inventory = array(

   array("type"=>"fruit", "price"=>3.50),
   array("type"=>"milk", "price"=>2.90),
   array("type"=>"pork", "price"=>5.43),

);
$price = array_column($inventory, 'price');
array_multisort($price, SORT_DESC, $inventory);
Posted by: Guest on June-03-2021
10

php sort array by key

$weight = [
    'Pete' => 75, 
    'Benjamin' => 89,
    'Jonathan' => 101
  ];  	
  ksort($weight);
Posted by: Guest on December-04-2019
0

php array sort by key

ksort(array &$array, int $sort_flags = ?): int
Posted by: Guest on September-06-2021
0

sort array php by key

$price = array_column($inventory, 'price'); //price is a key for the sort
array_multisort($price, SORT_DESC, $inventory);
Posted by: Guest on August-31-2021
1

php array sort

// Fonction de comparaison
function cmp($a, $b) {
    if ($a == $b) {
        return 0;
    }
    return ($a < $b) ? -1 : 1;
}
Posted by: Guest on May-28-2020

Browse Popular Code Answers by Language