Definition and Usage
The asort() function sorts an associative array in ascending order, according to the value.Syntax
asort(array,sortingtype);
| Parameter | Description |
|---|---|
| array | Required. Specifies the array to sort |
| sortingtype | Optional. Specifies how to compare the array elements/items. Possible values:
|
Example
Sort an associative array in ascending order, according to the value:
<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
asort($age);
?>
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
asort($age);
?>
OUTPUT :