php man page for asort

Query: asort

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

ASORT(3)								 1								  ASORT(3)

asort - Sort an array and maintain index association

SYNOPSIS
bool asort (array &$array, [int $sort_flags = SORT_REGULAR])
DESCRIPTION
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.
PARAMETERS
o $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 VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1 asort(3) example <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); asort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val "; } ?> The above example will output: c = apple b = banana d = lemon a = orange The fruits have been sorted in alphabetical order, and the index associated with each element has been maintained.
SEE ALSO
arsort(3), The comparison of array sorting functions. PHP Documentation Group ASORT(3)
Related Man Pages
usort(3) - php
array_walk(3) - php
array_unique(3) - php
collator_asort(3) - php
uksort(3) - php
Similar Topics in the Unix Linux Community
grep and delete 2nd duplicated of txt... -part2
How to replicate data using Uniq or awk
Perl: sorting by string
How to sort values inside one column?
Replace query by reading the file