The krsort() function is an inbuilt function in PHP which is used to sort an array by key in reverse order according to its index values. It sorts in a way that relation between indices and values is maintained.
bool krsort( $array, $sorting_type )
Parameters: This function accepts two parameters as mentioned above and described below:
- $array: This parameter specifies the array which to be sort. It is a mandatory parameter.
- $sorting_type: This is an optional parameter. There are different sorting types which are discussed below:
- SORT_REGULAR: The value of $sorting_type is SORT_REGULAR then items are compare normally.
- SORT_NUMERIC: The value of $sorting_type is SORT_NUMERIC then items are compares numerically.
- SORT_STRING: The value of $sorting_type is SORT_STRING then items are compares as string.
- SORT_LOCALE_STRING: The value of $sorting_type is SORT_STRING then items are compares as string, based on current locale.
Return Value: This function returns True on success or False on failure.
Below programs illustrate the krsort() function in PHP.
 = Copy  = Reset  = Contribute  = Placement  = Article  = Report  = Videos  = Graphics  = GeeksforGeeks  = Machine  = Technology
[z] = 1 [u] = 1000 [t] = 3 [s] = 2 [r] = 77 [q] = -11 [p] = 66 [o] = 55 [n] = 44 [d] = 33 [b] = 22 [a] = 11