Which of the following predefined PHP functions can be used to sort an array in descending order?
- sort($array, SORT_DESC)
- rsort($array)
- asort($array, SORT_DESC)
- arsort($array)
The correct option is 'rsort($array)'. This function is used to sort an array in descending order, where the keys stay associated with the corresponding values. 'sort($array, SORT_DESC)' and 'asort($array, SORT_DESC)' are incorrect, and 'arsort($array)' sorts in ascending order.
Loading...
Related Quiz
- Which of the following functions in PHP can be used to manipulate strings?
- Which PHP function is used to start a new session or to resume an existing session?
- In PHP, the fopen() function with 'w' as the mode will create a file if it doesn't exist and open it for ______.
- You want to output a variable's value along with some text in PHP. How would you use echo or print to do this?
- A common use case for the $_SERVER superglobal in PHP is to access the ______.