Reputation: 3076
<?php
$string = "qwertyuiopasdfghjklzxcvbnm";
$string = explode("", $string);
sort($string);
foreach ($string as $val) {
echo $val."<br>";
}
?>
I want this to output: a b c ... but how?
Upvotes: 0
Views: 1404
Reputation:
Your current call to explode()
isn't working -- it doesn't accept an empty first argument. Try using str_split()
instead:
$string = "qwertyuiopasdfghjklzxcvbnm";
$array = str_split($string, 1);
sort($array);
foreach ($array as $val) {
echo $val."<br>";
}
Upvotes: 6