As you know, the most common function of array sorting is sort ($ arr). it is used to sort by the key values of the array in ascending order, in addition, the sorted array key name is no longer the original key name, and is duplicated by the new array.
As you know, the most common function of array sorting is sort ($ arr). it is used to sort by the key values of the array in ascending order, in addition, the sorted array key name is no longer the original key name, but the key name is reset by the new array. sometimes we need more complex sorting, such as sorting by key names, ksort ($ arr) is used here. the Function sorts the values based on the key names of the array and maintains the original key-value relationship. the corresponding asort ($ arr) function, is to sort key values and maintain the original key-value relationship, the same principle, rsort (); arsort (); krsort (); function in addition to sorting by descending order, similar to sort (), rsort (), and ksort ();, array operations are an important foundation for PHP. we hope to make good use of them as an example of a one-dimensional array.
The instance code is as follows:
-