Easy Tutorial
❮ Func String Crypt Func Date Sunset ❯

PHP asort() Function

Complete PHP Array Reference Manual

Example

Sort an associative array in ascending order by value:


Definition and Usage

The asort() function sorts an associative array in ascending order by value.

Tip: Use the arsort() function to sort an associative array in descending order by value.

Tip: Use the ksort() function to sort an associative array in ascending order by key.

Syntax

Parameter Description
array Required. Specifies the array to sort.
sortingtype Optional. Specifies how to compare the array elements/items. Possible values: 0 = SORT_REGULAR - Default. Compare items normally (don't change types).<br> 1 = SORT_NUMERIC - Compare items numerically.<br> 2 = SORT_STRING - Compare items as strings.<br> 3 = SORT_LOCALE_STRING - Compare items as strings, based on the current locale.<br> 4 = SORT_NATURAL - Compare items as strings using natural ordering.<br> 5 = SORT_FLAG_CASE - Can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively.

Technical Details

Return Value: Returns TRUE on success, FALSE on failure.
PHP Version: 4+
--- ---

Complete PHP Array Reference Manual

❮ Func String Crypt Func Date Sunset ❯