How can an array be sorted in ascending order in PHP?
In PHP, you can use the sort() function to sort an array in ascending order. Here is an example:
$numbers = array(5, 3, 8, 2, 1);
sort($numbers);
print_r($numbers);
The output result is:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 5
[4] => 8
)
In the above example, the sort() function sorted the $numbers array, and then printed the sorted array using the print_r() function.