Krsort () Definition and usage
The Krsort () function reverses the array by key, preserving the original key for the set value.
The Second optional parameter contains an additional sort flag.
Returns TRUE if successful, otherwise FALSE is returned.
Grammar
Krsort (array,sorttype) parameter description
Array required. Specifies the array to sort.
SortType is optional. Specifies how the values of the array are arranged. Possible values:
Sort_regular-Default. Processed in their original type (without changing the type).
Sort_numeric-Handle the value as a number
Sort_string-handles the value as a string
Sort_locale_string-handles the value as a string, based on local settings *.
*: This value is new for PHP 4.4.0 and 5.0.2. Prior to PHP 6, the system's locale was used, which can be changed using setlocale (). From PHP 6, you must use the I18n_loc_set_default () function.
Example
Copy the Code code 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 above describes the PHP array function sequence krsort-the element key name of the array in descending order, keep the index relationship, including the contents of the content, I hope that the PHP tutorial interested in a friend helpful.