PHP offers a host of built in functions that we can use for sorting arrays. These functions allow us to sort arrays by key/value or ascending/decending order.
a: an prefix a, to function means the function sorts by value but maintains the association between key/value pairs the way it was.
k: an prefix k, to function means the function sorts by key but maintains the key/value associations.
The lack of k or a means the the function sorts by value but does not maintain the key/value association.
r: The prefix r, to function means the sorting order will be reversed.
u: The prefix u, to function means that a second argument is expected, the name of the user-defined function that specifies the ordering of any two elements that are being sorted.
Array Sorting Functions
-----------------------
Function Behavior
asort() Takes a single array as argument
0 Comment(s)