RE: Re[2]: [PHP] A to Z incremental
| From: | Pablo Gosse | Date: | Thu, 22 Apr 2004 18:01:09 +0000 |
| Subject: | RE: Re[2]: [PHP] A to Z incremental | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-184266@lists.php.net to get a copy of this message | ||
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:lists@pardel.net
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