Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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);
 
PREVIOUS NEXT
Tagged: #sort #array #key #php
ADD COMMENT
Topic
Name
8+5 =