|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42949 range('a', 'Z') has weird results
Submitted: 2007-10-12 13:49 UTC Modified: 2007-10-12 17:56 UTC
From: phpbug at fint dot org Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
50 + 11 = ?
Subscribe to this entry?

 [2007-10-12 13:49 UTC] phpbug at fint dot org
range('a', 'Z') gives random junk

Reproduce code:
foreach (range('a', 'Z') as $letter) {
   echo $letter;

Expected result:
a-z and A-Z (wishful thinking?) 

I am trying to recreate Perl's "@a=('a'..'z', 'A'..'Z');"

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-12 16:17 UTC] felipensp at gmail dot com
The order is A-Z, a-z.


$init = ord('A');
$end  = ord('z');

printf("Init.: %d | End.: %d\n", $init, $end);

for ($i = $init; $i <= $end; $i++) {
    print chr($i);
print "\n";

 [2007-10-12 17:56 UTC] phpbug at fint dot org
Apparently it also has non-alpha characters in it, which is why I was confused.

foreach (range('A', 'z') as $letter) {
  echo $letter;

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Jun 13 01:01:23 2021 UTC