Query: ksort
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
KSORT(3) 1 KSORT(3) ksort - Sort an array by keySYNOPSISbool ksort (array &$array, [int $sort_flags = SORT_REGULAR])DESCRIPTIONSorts an array by key, maintaining key to data correlations. This is useful mainly for associative arrays.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 ksort(3) example <?php $fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); ksort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val "; } ?> The above example will output: a = orange b = banana c = apple d = lemonSEE ALSOasort(3), The comparison of array sorting functions. PHP Documentation Group KSORT(3)
Related Man Pages |
---|
array_replace(3) - php |
arsort(3) - php |
sort(3) - php |
array_unique(3) - php |
each(3) - php |
Similar Topics in the Unix Linux Community |
---|
How to invert order in QuickSort |