The sort() function in PHP maintains the association between keys and values in an associative array.

  • FALSE
  • TRUE
The correct option is 2. The sort() function in PHP rearranges the elements of an array in ascending order based on their values. However, it does not maintain the association between keys and values in an associative array. After sorting, the keys may be reassigned in ascending order, and the original association between keys and values may be lost. It is important to note that sort() works primarily on indexed arrays and may not produce the expected results when used with associative arrays. If you need to maintain the association between keys and values, you can use other sorting functions like asort() or ksort(). Learn more: https://www.php.net/manual/en/function.sort.php
Add your answer
Loading...

Leave a comment

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