|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-01-15 04:18 UTC] psyko at wyred dot mine dot nu
[2004-01-15 04:52 UTC] mgf@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 28 12:00:01 2025 UTC |
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.