ID: 26914 Updated by: [EMAIL PROTECTED] Reported By: rschwartz at ec dot rr dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Any PHP Version: 4.3.4 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Using ++ on a string is defined to increment 'z' -> 'aa' -> ... -> 'az' -> 'ba' etc. The first value in this sequence which fails the <='z' test is 'za' (the value after 'yz'), which explains the observed behaviour of your 1st example. In the 3rd example, your expectation is just plain wrong. After the first iteration, 'a' will be incremented to 'b', which is plainly not <= 'aa', so the loop terminates immediately. Previous Comments: ------------------------------------------------------------------------ [2004-01-15 04:18:36] psyko at wyred dot mine dot nu Same for version 4.3.3 ------------------------------------------------------------------------ [2004-01-15 04:09:28] rschwartz at ec dot rr dot com Description: ------------ I was testing a for loop with incrementing alpha characters. For example, looping through a-z and printing those characters. It does not seem to work as expected. Reproduce code: --------------- Ex 1: for ($i = 'a'; $i <= 'z'; $i++) { echo $i; } Ex 2: for ($i = 'a'; $i < 'z'; $i++) { echo $i; } Ex 3: for ($i = 'a'; $i < 'aa'; $i++) { echo $i; } Expected result: ---------------- Ex 1: Print a-z. Ex 2: Print a-y. Ex 3: Print a-z. Actual result: -------------- Ex1 loops through to 'yz' and does not work as expected. Ex2 loops through to 'z', which is expected. Ex3 dies after the first iteration and only prints 'a'. I think this is an odd behavior. The < operator works as expected in this example but the <= operator does not. It doesn't seem like a consistent behavior. If I can remember correctly, I was able to get this to work on an earlier version sometime ago. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26914&edit=1