#42949 [Opn->Bgs]: range('a', 'Z') has weird results

From: Date: Fri, 12 Oct 2007 17:56:54 +0000
Subject: #42949 [Opn->Bgs]: range('a', 'Z') has weird results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118485@lists.php.net to get a copy of this message
ID: 42949 User updated by: phpbug at fint dot org Reported By: phpbug at fint dot org -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux PHP Version: 5.2.4 New Comment: Apparently it also has non-alpha characters in it, which is why I was confused. <?php foreach (range('A', 'z') as $letter) { echo $letter; } ?> Yields: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz Previous Comments: ------------------------------------------------------------------------ [2007-10-12 16:17:41] felipensp at gmail dot com The order is A-Z, a-z. <?php $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 13:49:56] phpbug at fint dot org Description: ------------ range('a', 'Z') gives random junk Reproduce code: --------------- <?php 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: -------------- a`_^]\[Z ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42949&edit=1

« previous php.bugs (#118485) next »