Krsort () of the php array function sequence-sort the element key names of the array in descending order to maintain the index relationship. Krsort () definition and usage the krsort () function sorts the array by key in reverse order, and retains the original key for the array value. The second optional parameter contains an additional sorting flag. If yes, return
Krsort () definition and usage
The krsort () function sorts the array by key in reverse order to reserve the original key for the array value.
The second optional parameter contains an additional sorting flag.
If yes, TRUE is returned. otherwise, FALSE is returned.
Syntax
Krsort (array, sorttype) parameter description
Array is required. Specifies the array to be sorted.
Sorttype is optional. Specifies how to arrange the values of an array. Possible values:
SORT_REGULAR-default. Process with their original type (without changing the type ).
SORT_NUMERIC-process the value as a number
SORT_STRING-process the value as a string
SORT_LOCALE_STRING-process the value as a string based on local settings *.
*: This value is newly added to PHP 4.4.0 and 5.0.2. Before PHP 6, you can use setlocale () to change the region settings of the system. From PHP 6, you must use the i18n_loc_set_default () function.
Example
The code is as follows:
$ My_array = array ("a" => "Dog", "B" => "Cat", "c" => "Horse ");
Krsort ($ my_array );
Print_r ($ my_array );
?>
Output:
Array
(
[C] => Horse
[B] => Cat
[A] => Dog
)
The http://www.bkjia.com/PHPjc/324455.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324455.htmlTechArticlekrsort () definition and usage of the krsort () function reversely sorts the array by the key, retaining the original key for the array value. The second optional parameter contains an additional sorting flag. If yes, the system returns...