How to Sort Associative Arrays in Descending Order According to the Value in PHP
in this lesson, we will see how to sort associative arrays in descending order according to the value in PHP, we will use the arsort() function that sorts an associative array in descending order according to the value.
Sort an associative array in descending order according to the value
The example below shows how you can sort an associative array in descending order according to the value in PHP.
$notes = array("jack" => 12, "adam" => 15, "sam" => 4);
//sort associative array in descending order according to the value
arsort($notes);
print_r($notes);
//Array ( [adam] => 15 [jack] => 12 [sam] => 4 )