PHP – Sort Array by Value – sort() and rsort()

The sort() and sort() functions allow you to sort arrays alphabetically.

<?php

$names = array('bob','sue','ted','ralph','mark','fred','marge');

print_r($names);

print "<br>";

sort($names);

print_r($names);

print "<br>";

rsort($names);

print_r($names);

?>

Be the first to comment

Leave a Reply