Answers for "sort alphabetically array php with key value"

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
-1

php array order alphabetically

// SORT ARRAY ALPHABETICALLY
$frutas = array("limón", "naranja", "banana", "albaricoque");
sort($frutas);
foreach ($frutas as $clave => $valor) {
    echo "frutas[" . $clave . "] = " . $valor . "\n";
}
Posted by: Guest on January-13-2022

Code answers related to "sort alphabetically array php with key value"

Browse Popular Code Answers by Language