#25829 [Opn->Bgs]: For loops against the alphabet don't function properly
| From: | elmicha@php.net | Date: | Fri, 10 Oct 2003 21:50:32 +0000 |
| Subject: | #25829 [Opn->Bgs]: For loops against the alphabet don't function properly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-48832@lists.php.net to get a copy of this message | ||
ID: 25829
Updated by: elmicha@php.net
Reported By: tim at timcrider dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Red Hat 9.0
PHP Version: 5CVS-2003-10-10 (dev)
New Comment:
It's a feature, not a bug. See
<http://www.php.net/language.operators.increment>.
Previous Comments:
------------------------------------------------------------------------
[2003-10-10 16:55:37] tim at timcrider dot com
Description:
------------
When trying to loop 'a' through 'z' using
for ($i = 'a'; $i < 'z'; $i++)
print $i;
it loops a-y as it should, but when you try
for ($i = 'a'; $i <= 'z'; $i++)
print $i;
instead of going a-z it goes a-yz doubling up the letters after a-z
a-z
aa-az
ba-bz
ca-cz
... etc
I know this breaks under php5, and under php4.
Reproduce code:
---------------
for ($i = 'a'; $i < 'z'; ++$i)
{
print "$i\n";
}
and
for ($i = 'a'; $i <= 'z'; ++$i)
{
print "$i\n";
}
Expected result:
----------------
abcdefghijklmnopqrstuvwxyz
(seperated by new lines)
Actual result:
--------------
abcdefghijklmnopqrstuvwxyzaaabacadaeaf....yxyyyz
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25829&edit=1