Ben Miller wrote:
In trying to make an alpha list, using the following:

for($i=A;$i<=Z;$i++) {

         ^ not a string technically! see what happens when
           you turn up error reporting to full (E_ALL).

        echo "$i";
}

rather than using a loop to generate (as others have shown you),
try this way instead:

<?php

// get the alphabet...
$letters = range("A", "Z");
// dump it to 'screen'
echo join(",", $letters);

?>

which will output:

A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z


Produces:
A
B
C...
X
Y
Z
AA
AB
AC...
AX
AY
AZ... all the way to YZ.


What am I doing wrong that it's not stopping at just plain old "Z", without
moving on to "AA" and continuing?

it's down to a lack of understanding about the way php autocasts stuff ....
maybe this output will help you to understand it:

$> php -r '
var_dump(
        (Z <= Z),
        ("Z" <= "Z"),
        ord("Z"),
        ord("AA"),
        (Z <= 90),
        ("Z" <= 90),
        (AA <= Z),
        ("AA" <= "Z"));'
bool(true)
bool(true)
int(90)
int(65)
bool(true)
bool(true)
bool(true)
bool(true)





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to