|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6599 strange behaviour in for loops with strings++
Submitted: 2000-09-07 08:53 UTC Modified: 2000-09-20 01:47 UTC
From: adobernig at netway dot at Assigned:
Status: Closed Package: Strings related
PHP Version: 4.0.2 OS: LINUX RH 6.1
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: adobernig at netway dot at
New email:
PHP Version: OS:


 [2000-09-07 08:53 UTC] adobernig at netway dot at
for ($char="A";$char<="Z";$char++)
echo "$char - ";

the last char displayed by this script 
is not "Z" but "YZ"
with ever other letter it works as it should


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-20 01:46 UTC]
This is an intended behaviour, ++ on strings is "magical" in PHP, like in Perl, so "Z"++ is "AA".
 [2003-04-08 08:48 UTC] martin at tack dot se
I just hit this aswell. I personally dislike the behaviour. However, rewrite your loop like this to get the expected behaviour:

for ($i=ord('A'); $i<=ord('Z'); $i++)
    echo chr($i)."<br>";
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Aug 09 23:03:35 2022 UTC