php arsortFunction is used to sort the elements in array in descending order. If the sorting is successful, it returns true, otherwise it returns false. This article is dedicated to Everyone explains the basic syntax and usage examples of the arsort function. Friends who need it can refer to
arsort to sort the array in descending order and maintain the index relationship.
Basic syntax
bool arsort ( array &$array [, int $sort_flags = SORT_REGULAR ] )
This function sorts the array in descending order, and the index of the array remains associated with the unit.
The arsort function is mainly used to sort associative arrays where the order of the units is important.
Parameter introduction:
Parameter | Description |
---|---|
array | Required. The input array. |
sort_flags |
Optional. Specifies how the elements/items of an array are arranged. Possible values:
|
Description
The arsort() function sorts the array in reverse order and maintains the index relationship. Mainly used for sorting associative arrays where the order of cells is important.
The optional second parameter contains additional sorting flags.
Return value
Returns TRUE on success, or FALSE on failure.
Example:
<?php $age=array("Bill"=>"60","Steve"=>"56","Mark"=>"31");arsort($age); ?>
The above is the detailed content of Detailed introduction to php arsort array descending order_php example. For more information, please follow other related articles on the PHP Chinese website!