PHP krsort () function
Examples
Associative array in accordance with the keys in descending order:
<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
krsort($age);
?>
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
krsort($age);
?>
Running instance »
Definition and Usage
krsort () function for an associative array in accordance with the keys in descending order.
Tip: Use ksort () function for an associative array in accordance with the keys in ascending order.
Tip: Use arsort () function in accordance with an associative array key in descending order.
grammar
krsort( array,sortingtype );
参数 | 描述 |
---|---|
array | 必需。规定要进行排序的数组。 |
sortingtype | 可选。规定如何排列数组的元素/项目。可能的值:
|
technical details
return value: | If successful it returns TRUE, on failure returns FALSE. |
---|---|
PHP version: | 4+ |
Complete PHP Array Reference