Re: When is "z" != "z" ?
| From: | tedd | Date: | Sun, 04 Jun 2006 19:13:30 +0000 |
| Subject: | Re: When is "z" != "z" ? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-237367@lists.php.net to get a copy of this message | ||
At 11:08 AM -0700 6/4/06, Rasmus Lerdorf wrote:
>tedd wrote:
>>But, if you use --
>>
>>for ($i="a"; $i<="z"; $i++)
>> {
>> echo($i);
>> }
>>
>>-- it prints considerably more characters after "z" than what one would normally
>>expect -- why is that?
>>
>>Just stopping at "z" would seem to make more sense, wouldn't it? After all,
>>when $i = "z" in the first expression, then wouldn't $i be equal to "z" in
>>the second expression and thus halt the operation?
>>
>>What am I missing here?
>
>It's a bit of a quirk. "z"++ is "aa" and "aa" <
>"z". I would guess this would loop until until just before "za" which would be
>"yz".
>
>It's a bit like looping through the hexadecimal characters. You would have the same
>effect. However instead of being base-16 with 0-9-a-f you have base-26 using a-z.
>
>-Rasmus
-Rasmus:
Ahhh -- I see -- sort of.
However, if it has to be a base then it's more like base-676, going from a to yz. Like DEC has
10 elements and HEX has 16 elements, this has 676 elements.
But, what brothers me about the routine, is that is DOES print "z" where it is supposed
to. In other words, the characters a-z are output before continuing with aa and so on. The operation
doesn't end with "z".
Shouldn't the expression $i ="z" be true when $i="z" and if $i is greater,
then be false?
For example, please review:
http://xn--ovg.com/a1.php
You can here that when $i = "z", then the condition is true and it prints
"Look". One would think that anything greater than that point would be false and thus end
the loop. But here we have an example of how we can have something equal to something and then by
adding 1 to it, it becomes smaller. That's not logical.
Furthermore, if it was to work like a base, then I would expect "z" to the the last
character, not the 26th.
Here's another way to look at it. All characters before "z" are less than
"z" -- correct? So, what value are all characters after "z" (i.e.,
"aa-yz")? They cannot be greater than, nor can they be less than. So, what are they?
tedd
PS: It was just a day, or so ago, that I said I didn't want disagree with you and now what have
you got me into? <running for cover looking for rock to program with>
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com