Which of the following are true about sorting arrays in PHP?

  • Sorting can be performed on both indexed and associative arrays.
  • Sorting modifies the original array.
  • Sorting is always done in ascending order.
  • Sorting is only applicable to numeric arrays.
The correct option is 1. Sorting can be performed on both indexed and associative arrays in PHP. You can sort arrays based on their values while maintaining key-value associations (for associative arrays) or simply rearrange the elements in ascending or descending order (for indexed arrays). The sort() and rsort() functions modify the original array, while functions like asort(), ksort(), arsort(), and krsort() maintain the original array and sort it based on certain criteria. Sorting in PHP is not limited to numeric arrays; it can be applied to arrays with various types of values. Learn more: https://www.php.net/manual/en/array.sorting.php
Add your answer
Loading...

Leave a comment

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