Xell Zhang wrote:
Hello all, I met a very strange problem today. Take a look at the codes below: for ($i = 'A'; $i < 'Z'; $i++) { echo $i . ' '; } If you think the output is A-Z, please run it on your server and try. Who can tell me why the result is not A-Z?
The result doesnt include the 'Z', as if $i = 'Z', then $i < 'Z' would return false, so would leave the loop there before echoing it out.
PHP seems to increment the alphabet by A, B, C.... Y, Z, AA, AB, AC.... So you could use: for ($i = 'A'; $i != 'AA'; $i++) { echo $i . ' '; } Using $i < 'AA' doesn't seem to work either, which I find a bit odd. Hope that helps, Darren -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php