Sorting an Array in Alphabetical Order in PHP


Sort the elements of an array in ascending order with sort().

Source Code

$array = ["banana", "cherry", "apple"];
sort($array);
print_r($array); // The array is now sorted alphabetically
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments