php rsort() function
Translation results:
英[sɔ:t] 美[sɔ:rt]
n.Classification, category; quality, nature; method; a group
vt.& vi.Classification; rectification, arrangement ; suitable for
vt. to select; to classify; to put in order
vi. to classify; to communicate; to coordinate
Third person singular: sorts Plural: sorts Present participle: sorting past tense: sorted past participle: sorted
php rsort() functionsyntax
Function: Sort the numerical array in descending order.
Syntax: rsort(array,sortingtype)
Parameters:
Parameter | Description |
array | Required. Specifies the array to be sorted. |
sortingtype | Optional. Specifies how elements/items of an array are compared. Possible values: 0 = SORT_REGULAR - Default. Put each item in regular order (Standard ASCII, don't change the type). 1 = SORT_NUMERIC - treat each item as a number. 2 = SORT_STRING - Treat each item as a string. 3 = SORT_LOCALE_STRING - Treat each item as a string, based on the current locale (can be changed with setlocale()). 4 = SORT_NATURAL - Treat each item as a string, using natural sorting like natsort(). 5 = SORT_FLAG_CASE - Strings can be sorted in combination (bitwise OR) with SORT_STRING or SORT_NATURAL, case-insensitively. |
Description: Assign new key names to the cells in array. This will delete the original keys rather than just reorder them. Returns TRUE if successful, FALSE otherwise. The optional second parameter contains additional sorting flags.
php rsort() functionexample
<?php $a=array("a"=>"php中文网","b"=>"西门","c"=>"php.cn"); rsort($a); print_r($a); ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
Array ( [0] => 西门 [1] => php中文网 [2] => php.cn )