Share the sort, asort, and ksort usages of the PHP array, which is a simple example of the use of sort, asort, and Ksort, with comments detailing them.
The use of sort, asort, and Ksort in the ordering of PHP arrays.
<? PHP $arr Array (' d ' = ' sdf ', ' r ' = ' sdf ', ' a ' = ' eee '); // sort ($arr);//The value of the array is re-//asort, the previous key value is deleted, and the index array is changed to the indexed arrays ($arr);//The array is re-sorted by value, and the index relationship is maintained, and the indexed and associative arrays apply Ksort ($arr// arrays are re-sorted by key value and maintain index relationships, indexed arrays and associative arrays apply//correspond to reverse order and Rsort Arsort krsort//use function compare Usort Uksort Uasort the second parameter for the comparison function needs to return a value equal to less than 0 when the first parameter equals less than the second argument, and the floating-point number will only take the integer part //www.jbxue.comprint_r($arr );? >
In this example, only ksort usage is demonstrated, and you can test the results of sort and asort in order to deepen your impressions and grasp them firmly.
Sorting the PHP array sort, asort, and Ksort usage