PHP - Function rsort()
Syntax
rsort( $array [, $sort_flags] );
Definition and Usage
This function sorts an array in reverse order (highest to lowest).
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
array(Required) It specifies an array. |
| 2 | sort_flags(Optional) It specifies how to sort the array values. Possible values −
|
Return Value
It returns TRUE on success or FALSE on failure.
Example
Try out following example −
<?php
$input = array("d"=>"lemon", "a"=>"orange", "b"=>"banana" );
rsort($input);
print_r($input);
?>
This will produce following result −
Array ( [0] => orange [1] => lemon [2] => banana )
php_function_reference.htm
Advertisements