How to sort an array alphabetically?

I have generated an array with 5 random items, I sort them in alphabetical order?
<?php

 function randomString($count = 5, $length = 13) {
 $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
 $charsLen = strlen($chars);
 $res = array();
 for($i = 0; $i < $count; $i++) {
 $tmp = ";
 for ($j = 0; $j < $length; $j++) {
 $tmp .= $chars[rand(0, $charsLen - 1)];
}
 $res[] = $tmp;
}
 return $res;

}

print_r (randomString());

?>
June 14th 19 at 21:04
1 answer
June 14th 19 at 21:06
Solution
$arr = randomString();
sort($arr);
print_r($arr);

Find more questions by tags PHP