Looping through letters instead of numbers

Here are a few examples.

for ($i =ord( 'A'); $i <= ord('Z'); $i++){
  print($i . ' '); #> outputs 65,66,67,...,90
}
for($i=chr('65'), $j=0; $i<=chr('90'), $j<=25; $i++, $j++){
  print($i . ' '); #> outputs A,B,C,...,Z
}

Below is an explanation of two functions chr() and ord().

chr ( int ascii ) takes the integer

ord ( string string ) takes the string

or

for($letters = range('A','Z'), $i=0; isset($letters{$i}); $i++)
echo $letters{$i}." ";

http://www.issociate.de/board/post/216585/Letters_loop.html »

By the way A=65 and Z=90 and the rest of the letters are in between. You could print A in html as "ampersand #65;".

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.