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