Copyright © tutorialspoint.com
| arsort( $array [, $sort_flags] ); |
This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant.
| Parameter | Description |
|---|---|
| array | Required. Specifies an array. |
| sort_flags | Optional. Specifies how to sort the array values. Possible values:
|
Returns TRUE on success or FALSE on failure.
Try out following example:
<?php
$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana" );
arsort($fruits);
print_r($fruits);
?>
|
This will produce following result:
Array ( [a] => orange [d] => lemon [b] => banana ) |
Copyright © tutorialspoint.com