RE: [PHP] stepping through alphabet

From: Date: Wed, 19 Nov 2003 14:37:34 +0000
Subject: RE: [PHP] stepping through alphabet
Groups: php.general 
Request: Send a blank email to php-general+get-170289@lists.php.net to get a copy of this message
Yes, I found that the loop was written kind of backwards and would create a never ending loop. I never thought to try setting $letter='A' before. I didn't think you could loop through the Alphabet like that. But I did a little changing to your loop and it works fine like this now:
        $letter='A';
        for($i=0;$i<=25;$i++){
                echo $letter++." ";
        }
Thank You So Much Steve At 08:24 AM 11/19/2003, you wrote:
[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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#170289) next »