This paper illustrates the use of sort, asort and ksort in the sequence of PHP arrays for reference. The specific examples are as follows:
02 |
$arr = Array (' d ' => ' SDF ', ' R ' => ' SDF ', ' a ' => ' eee '); |
03 |
Sort ($arr); Rearrange the values of the array, delete the previous key value, and become an indexed array |
04 |
Asort ($arr); The array is rearrange by value and the index relationship is maintained, and both the indexed and associative arrays apply |
05 |
Ksort ($arr); The array of arrays is queued according to the key value and the index relationship is maintained, and both the indexed and associative arrays apply |
07 |
corresponding reverse order and Rsort Arsort Krsort |
08 |
Use a function to compare a usort uksort uasort a function with a comparison that returns a value that is equal to or less than 0 when the first argument is equal to less than the second argument only takes the whole number of points |
The example of this article is only a demonstration of ksort usage, interested readers can test the results of sort and asort, in order to deepen the impression, firmly grasp. I hope this example will help you with PHP program design.