PHP - Function arsort()
Syntax
arsort( $array [, $sort_flags] );
Definition and Usage
This function sorts an array such that array indices maintain their correlation with the array elements they are associated with.
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
array(Required) It specifies an array. |
| 2 | sort_flags(Optional) It specifies how to sort the array values. Possible values −
|
Return Value
It returns TRUE on success or FALSE on failure.
Example
Try out following example −
<?php
$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana" );
arsort($fruits);
print_r($fruits);
?>
This will produce the following result −
Array ( [a] => orange [d] => lemon [b] => banana )
php_function_reference.htm
Advertisements