PHP uasort() Function
Complete PHP Array Reference Manual
Example
Sort the elements of the $arr array by value using a user-defined comparison function:
4,"b"=>2,"c"=>8,d=>"6"); uasort($arr,"my_sort"); ?>Run Example »
Definition and Usage
uasort() sorts an array by value using a user-defined comparison function.
**Tip:** Please use uksort() function sorts an array by key using a user-defined comparison function.
Syntax
uasort(
array,myfunction
);
| Parameters | Description |
|---|---|
| array | Required. Specifies the array to sort. |
| myfunction | Optional. A string defining a callable comparison function. If the first argument is <, =, or > the second argument, the comparison function must return an integer <, =, or > 0 accordingly. |
Technical Details
| Return Value: | Returns TRUE on success, FALSE on failure. |
|---|---|
| PHP Version: | 4+ |
Complete PHP Array Reference Manual