Code snippet: Print out A-Z in PHP
If you have ever wanted to printed out the alphabet without having to manually write out 26 of the same link, button, etc. use this handy PHP script:
for($i=97; $i<123; $i++) {
print(chr($i) . ' ');
}
If you needed to print out links that might direct a user to a set of results for that letter, for example:
for($i=97; $i<123; $i++) {
print('<a href="results.php?letter='.chr($i).'">'.chr($i).'</a> ');
}
To use uppercase letters instead of lowercase, replace the numbers in the for loop with 65 and 90.