Query: arsort
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
ARSORT(3) 1 ARSORT(3) arsort - Sort an array in reverse order and maintain index associationSYNOPSISbool arsort (array &$array, [int $sort_flags = SORT_REGULAR])DESCRIPTIONThis 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.PARAMETERSo $array - The input array. o $sort_flags - You may modify the behavior of the sort using the optional parameter $sort_flags, for details see sort(3).RETURN VALUESReturns TRUE on success or FALSE on failure.EXAMPLESExample #1 arsort(3) example <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); arsort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val "; } ?> The above example will output: a = orange d = lemon b = banana c = apple The fruits have been sorted in reverse alphabetical order, and the index associated with each element has been maintained.SEE ALSOasort(3), The comparison of array sorting functions. PHP Documentation Group ARSORT(3)
Related Man Pages |
---|
array_walk_recursive(3) - php |
asort(3) - php |
array_unique(3) - php |
collator_asort(3) - php |
uksort(3) - php |
Similar Topics in the Unix Linux Community |
---|
How to replicate data using Uniq or awk |
Help with array comparison |
Column update |
Perl: sorting by string |
Getting contents of line using a selected one as reference |