php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25829 For loops against the alphabet don't function properly
Submitted: 2003-10-10 16:55 UTC Modified: 2003-10-10 17:50 UTC
From: tim at timcrider dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2003-10-10 (dev) OS: Red Hat 9.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tim at timcrider dot com
New email:
PHP Version: OS:

 

 [2003-10-10 16:55 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-10 17:50 UTC] elmicha@php.net
It's a feature, not a bug. See <http://www.php.net/language.operators.increment>.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 12:01:35 2025 UTC