PHP - Function krsort()
Syntax
krsort ( $array, $sort_flag );
Definition and Usage
The krsort() function sorts an array by the keys in reverse order. The values keep their original keys.
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
array(Required) It specifies an array |
| 2 |
sort_flag(Optional) It specifies how to sort the array values. Possible values −
|
Return Value
This function returns TRUE on success, or FALSE on failure.
Example
Try out following example −
<?php $transport = array( a=>'foot', b=>'bike', c=>'car', d=>'plane'); krsort($transport); print_r($transport); ?>
This will produce the following result −
Array ( [d] => plane [c] => car [b] => bike [a] => foot )
php_function_reference.htm
Advertisements