ID: 48545 Updated by: j...@php.net Reported By: robccsilva at gmail dot com -Status: Open +Status: Bogus Bug Type: Variables related Operating System: Windows XP PHP Version: 5.2.9 New Comment:
There are several user comments about this on page: http://www.php.net/manual/en/control-structures.for.php Z being "less" than AA causes this "unexpected" behaviour which is quite expected. You could also do it like this: foreach(range('A', 'Z') as $letter) echo $letter; Previous Comments: ------------------------------------------------------------------------ [2009-06-13 16:34:42] robccsilva at gmail dot com Description: ------------ Trying to write: ABCDEFGHIJKLMNOPQRSTUVWXYZ 1. ABCDEFGHIJKLMNOPQRSTUVWXY 2. ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF...SYTYUYVYWYXYYYZ 3. ABC...ZZY Reproduce code: --------------- <html> <body> <?php echo "Hello World!<br /><br />\r\n"; echo "On this test case I will write the letters A-Z the easy way!<br />\r\n"; echo "If you the result of each test, you the man!<br />\r\n"; echo "<br /><br />\r\n"; echo "On this small test you might 'crash' your browser, run at your risk! ;)<br />\r\n"; echo "<br /><br />\r\n"; echo "1. I think as a noob, so the first script should get me to the 'Z' as follows:<br />\r\n"; for ($letter = 'A'; $letter < 'Z'; $letter++) { echo $letter; } echo "<br /><br />\r\n"; echo "2. As a noobster, I want to reach 'Z' as follows:<br />\r\n"; for ($letter = 'A'; $letter <= 'Z'; $letter++) { echo $letter; } echo "<br /><br />\r\n"; echo "3. Being a major noob, decided to reach 'Z' as follows:<br />\r\n"; for ($letter = 'A'; $letter < 'Z'+1; $letter++) { echo $letter; } ?> </body> </html> Expected result: ---------------- Write ABCDEFGHIJKLMNOPQRSTUVWXYZ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48545&edit=1