How to use php usort() function
php usort() function definition and usage
usort() usage User-defined comparison function sorts arrays.
Syntax
usort(array,myfunction);
Parameters
array required. Specifies the array to be sorted.
myfunction Optional. A string that defines a callable comparison function. If the first argument is <, =, > and the second argument is, the corresponding comparison function must return an integer of <, =, > 0.
Example
Sort the elements of the $a array using a user-defined comparison function:
Output:
2 4 6 8
The above is the detailed content of How to use php usort function. For more information, please follow other related articles on the PHP Chinese website!