weird PHP range() issue

Fint

[H]ard|Gawd
Joined
Jun 11, 2004
Messages
1,046
I think I'm using this function slightly wrong, but the output is really odd...

PHP:
<?php
 foreach (range('a', 'Z') as $letter) {
     echo $letter;
 }
?>

But it outputs

Can anybody else verify this?
 
Code:
<?php
 foreach (range('A', 'z') as $letter) {
     echo $letter;
 }
?>
outputs
Code:
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz
 
Ah, ok, that makes sense. I didn't figure that any of [\]^_` would be a list of a-z.

Thanks.
 
In Perl, I would do
@alpha=('a'..'z', 'A'..'Z');

In PHP, the best way I've found is to do
Code:
$lower=range('a','z');
$upper=range('A','Z');
$alpha=array_merge($lower,$upper);

Is there a "better" way?
 
Back
Top