Paul wrote:
> Hello Pablo,
> 
> Thursday, April 22, 2004, 4:05:23 PM, you wrote:
> 
>>> Hi!
>>> Got this script:
>>> 
>>> <?php
>>> for($i='A';$i<='Z';$i++){  echo $i.' | ';  }
>>>> 
>>> 
>>> The output is:
>>> 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 |  AA | AB | AC |  ... YX | YY
>>> | YZ 
>>>> 
>>> 
>>> where is should display only letters from A to Z.
>>> Why is that?
>>> 
> 
>> Hi, Paul. Try this instead.
> ...
> 
> 
> Thanks Pablo!
> I know that but I was curios why that happens.
> 
> 
> --
> Best regards,
>  Paul                            mailto:[EMAIL PROTECTED]

Hi Paul.

Since you're dealing with a string, A is less than AA which will be less
than Z.  It's stopping at YZ because if it were to increment once more,
it would be ZZ, which (again, because this is a string) is greater than
Z so thus the loop exits.

HTH.

Cheers,
Pablo

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

Reply via email to