Easy Tutorial
❮ Func Mysqli Connect Func String Strspn ❯

PHP rsort() Function

Complete PHP Array Reference Manual

Example

Sort the elements of the $cars array in descending alphabetical order:


Definition and Usage

The rsort() function sorts an indexed array in descending order.

Tip: Use the sort() function to sort an indexed array in ascending order.

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+
--- ---

More Examples

Example 1

Sort the elements of the $numbers array in descending numerical order:

Example 2

Treat each item as a number and sort the elements of the $cars array in descending order:


❮ Func Mysqli Connect Func String Strspn ❯