Complete the code to sort the array in ascending order.
<?php $numbers = [4, 2, 8, 6]; [1]($numbers); print_r($numbers); ?>
The sort function sorts the array in ascending order by values and reindexes the keys.
Complete the code to sort the array in descending order.
<?php $letters = ['a', 'd', 'b', 'c']; [1]($letters); print_r($letters); ?>
The rsort function sorts the array in descending order by values and reindexes the keys.
Fix the error in the code to sort the array by keys in ascending order.
<?php $ages = ['John' => 25, 'Jane' => 22, 'Doe' => 30]; [1]($ages); print_r($ages); ?>
The ksort function sorts the array by keys in ascending order.
Fill both blanks to sort the array by values in ascending order while preserving keys.
<?php $scores = ['Alice' => 85, 'Bob' => 92, 'Charlie' => 78]; [1]($scores); print_r($scores); ?>
The asort function sorts the array by values in ascending order and preserves the keys.
Fill all three blanks to sort the array by values in descending order while preserving keys.
<?php $grades = ['Math' => 90, 'Science' => 85, 'English' => 88]; [1]($grades); print_r($grades); ?>
The arsort function sorts the array by values in descending order and preserves the keys.