RE: [PHP] stepping through alphabet
| From: | Jay Blanchard | Date: | Wed, 19 Nov 2003 14:24:54 +0000 |
| Subject: | RE: [PHP] stepping through alphabet | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-170285@lists.php.net to get a copy of this message | ||
[snip]
for ($letter = 'A'; $letter++; $letter <= 'Z')
echo "<a
href=\"?action=alphabet&letter=$letter\">$letter</a>\n";
[/snip]
I tested this and found two small problems. The code works if you do
this (I was myself amazed that letters would increment)
for($letter = 'A'; $letter < 'Z'; $letter++){
echo $letter . "\n";
}
The problem seems to be that you cannot use <='Z' for some reason, as
the array becomes quite lengthy, as if 'Z' doesn't work properly. But,
if I do this
for($letter = 'A'; $letter < 'Z'; $letter++){
echo $letter . "\n";
}
echo $letter . "\n";
The second echo statement echos the 'Z' properly.