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
- How to get the function name inside a function in PHP ?
- D3.js | d3.max() function
- PHP | exp() Function
- CSS | hsl() Function
- p5.js | nfp() Function
- D3.js | d3.hcl() Function
- PHP | dir() Function
- D3.js | d3.map.get() Function
- D3.js | d3.map.has() Function
- p5.js | arc() Function
- p5.js | nfs() Function
- PHP | Ds\Set add() Function
- PHP | Ds\Set last() Function
- CSS | rgb() Function
- D3.js | d3.map.set() Function
- D3.js | d3.min() function
- p5.js | box() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ManasChhabra2