How to Sort an Array in Ascending Order in PHP

Updated 2 weeks ago admin PHP

In this lesson, we will see how to sort an array in ascending order in PHP. We will use the sort() function that sorts an indexed array in ascending order.

Sort an Array in Ascending Order in PHP

The example below shows how you can sort an array in ascending order in PHP.

$notes = array( 12, 15, 4);
//sort array in ascending order
sort($notes);
print_r($notes);
//Array ( [0] => 4 [1] => 12 [2] => 15 )