Easy Tutorial
❮ Func String Html Entity Decode Func Filesystem Fclose ❯

PHP arsort() Function

Complete PHP Array Reference Manual

Example

Sort an associative array in descending order by value:


Definition and Usage

The arsort() function sorts an associative array in descending order by value.

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

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

Syntax

Parameter Description
array Required. Specifies the array to sort.
sortingtype Optional. Specifies how to sort the array elements/items. Possible values: 0 = SORT_REGULAR - Default. Sort items normally (don't change types).<br> 1 = SORT_NUMERIC - Sort items numerically.<br> 2 = SORT_STRING - Sort items as strings.<br> 3 = SORT_LOCALE_STRING - Sort items as strings, based on the current locale (can be changed with setlocale()).<br> 4 = SORT_NATURAL - Sort items as strings using natural ordering like natsort().<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+
--- ---
❮ Func String Html Entity Decode Func Filesystem Fclose ❯