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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *