Norbert Wenzel wrote:
Hi,
just for fun I tried the following code:
<code>
for($letter = 'A'; $letter <= 'Z'; ++$letter) {
echo($letter . ' ');
}
</code>
What surprised me was the output, which looked like this:
A B C [...] Y Z AA AB AC [...] YY YZ
I don't have any idea how these letters get printed out, so I'd
appreciate any guesses or explanations.
This was discussed a lot a couple months back (Rasmus answered it about
20 times). This is my rendition.
When you increment a string, you get:
'A' + 1 is 'B'
...
'Z' + 1 is 'AA'
Because of how string comparisons go, 'AA' is greater than 'Z' (strings
are compared letter by letter), so the loop won't terminate at 'Z', like
you'd expect.
jon
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php