Monday, 10 December 2012

PHP Alphabet Loop (generate alphabet with php script)



You can use this loop to generate and show all the alphabet letters with your php script. A simple way to output all the letters of the alphabet in a loop. You can use this code for making quicklinks for filtering, etc.


<?php
for ($i=65; $i<=90; $i++) {
$Letter = chr($i);
print $Letter ." ";
?>
Another cool way to do it would be to use the PHP range funtion which can take the letters of the alphabet as parameters in a loop like this:

<?php foreach(range('A','Z') as $i) echo $i; ?>


Share:

No comments:

Post a Comment