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