Home > Article > Backend Development > PHP uses asort() to sort associative arrays by value, asort array_PHP tutorial
This article describes the example of php using asort() to sort associative arrays by value. Share it with everyone for your reference. The specific analysis is as follows:
PHP uses asort() to sort the associative array by value. The difference from sort is that sort assigns new key names to the cells in the array. The original key name will be deleted.
$nums = array("one"=>5,"two"=>2,"three"=>1); asort( $nums ); foreach ( $nums as $key => $val ) { print "$key = $val<br />"; }
I hope this article will be helpful to everyone’s PHP programming design.