PHP rsort () function
Examples
$ Cars array elements in alphabetical in descending order:
<?php
$cars=array("Volvo","BMW","Toyota");
rsort($cars);
?>
$cars=array("Volvo","BMW","Toyota");
rsort($cars);
?>
Running instance »
Definition and Usage
rsort () function array of numeric values in descending order.
Tip: Use the sort () function array of numeric values in ascending order.
grammar
rsort( array,sortingtype );
参数 | 描述 |
---|---|
array | 必需。规定要进行排序的数组。 |
sortingtype | 可选。规定如何排列数组的元素/项目。可能的值:
|
technical details
return value: | If successful it returns TRUE, on failure returns FALSE. |
---|---|
PHP version: | 4+ |
More examples
Example 1
$ Numbers array elements in descending order according to numbers:
<?php
$numbers=array(4,6,2,22,11);
rsort($numbers);
?>
$numbers=array(4,6,2,22,11);
rsort($numbers);
?>
Running instance »
Example 2
As the numbers to deal with every one, and $ cars array elements in descending order:
<?php
$cars=array("Volvo","BMW","Toyota");
rsort($cars,SORT_NUMERIC);
?>
$cars=array("Volvo","BMW","Toyota");
rsort($cars,SORT_NUMERIC);
?>
Running instance »
Complete PHP Array Reference