$arr = array( a=>'bike', b=>'van', c=>'car', d=>'plane'); krsort($arr); print_r($arr);Output:-
Array ( [d] => plane [c] => car [b] => van [a] => bike )
Description:-
The krsort() function sorts an array according to their key in reverse order and the value keeps their original key.
Syntax:-
krsort ( $array, $sort_flag );
Parameter:-
1. Array(required):- It specifies an array.
2.sort_flag(Optional):- It specifies how to sort the array values. Possible values −
- SORT_REGULAR − Default. Treat values as they are (don't change types)
- SORT_NUMERIC − Treat values numerically
- SORT_STRING − Treat values as strings
- SORT_LOCALE_STRING − Treat values as strings, based on local settings
0 Comments