PHP asort() Function
Complete PHP Array Reference Manual
Example
Sort an associative array in ascending order by value:
"35","Ben"=>"37","Joe"=>"43"); asort($age); ?>Run Example »
Definition and Usage
The asort() function sorts an associative array in ascending order by value.
**Tip:** Please use arsort() function to sort an associative array in descending order by value.
**Tip:** Please use ksort() function to sort an associative array in ascending order by key.
Syntax
asort(
array,sortingtype);
| Parameters | Description |
|---|---|
| array | Required. Specifies the array to sort. |
| sortingtype | Optional. Specifies how to arrange the elements/items of the array. Possible values:
|
Technical Details
| Return Value: | Returns TRUE on success, FALSE on failure. |
|---|---|
| PHP Version: | 4+ |