What built-in PHP function can be used to sort an array in ascending order?
To sort an array in ascending order in PHP, you can use the built-in function `sort()`. This function rearranges the elements of the array in ascending order based on their values. It does not maintain the keys of the elements, so if you need to preserve the keys, you should use the `asort()` function instead.
$numbers = [4, 2, 8, 6, 3];
sort($numbers);
print_r($numbers);
Keywords
Related Questions
- What are the advantages and disadvantages of using sessions and submit buttons as a workaround for the current issue with $_GET['seite']?
- What are some best practices for passing data between a popup and a main page without refreshing in PHP?
- What PHP function can be used to retrieve the IP address of a dynamic domain like a dyndns.org address?