Easy Tutorial
❮ Pdo Errorinfo Func Ftp Connect ❯

PHP krsort() Function

Complete PHP Array Reference Manual

Example

Sort an associative array by key in descending order:


Definition and Usage

The krsort() function sorts an associative array by key in descending order.

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

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

Syntax

Parameter Description
array Required. Specifies the array to sort.
sortingtype Optional. Specifies how to arrange the array elements/items. Possible values: 0 = SORT_REGULAR - Default. Sort items normally (Standard ASCII, do not change types).<br> 1 = SORT_NUMERIC - Treat each item as a number.<br> 2 = SORT_STRING - Treat each item as a string.<br> 3 = SORT_LOCALE_STRING - Treat each item as a string, based on the current locale (can be changed with setlocale()).<br> 4 = SORT_NATURAL - Treat each item as a string, 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+
--- ---
❮ Pdo Errorinfo Func Ftp Connect ❯