Re: [PHP] A very strange loop!

2007-07-09 Thread Fredrik Thunberg
For exactly the same reason as for( $i = 0; $i 10; $i++) produces 0-9 It loops whule $i is lesser than 'Z' When $i becomes 'Z' it stops and doesn't echo But i guess you're having trouble with (note the '='): for ($i = 'A'; $i = 'Z'; $i++) { echo $i . ' '; } This might produce a wierd

Re: [PHP] A very strange loop!

2007-07-09 Thread Jason
Because you need $i= 'Z' to get Z included as well. J At 08:49 09/07/2007, 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.

Re: [PHP] A very strange loop!

2007-07-09 Thread Fredrik Thunberg
No, that won't work Either use != 'AA' or for( $i = ord('A'); $i = ord('Z'); $i++) { echo chr( $i ) . ' '; } Jason skrev: Because you need $i= 'Z' to get Z included as well. J At 08:49 09/07/2007, Xell Zhang wrote: Hello all, I met a very strange problem today. Take a look at the codes

Re: [PHP] A very strange loop!

2007-07-09 Thread Chris
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? Try foreach (range('a', 'z') as

Re: [PHP] A very strange loop!

2007-07-09 Thread clive
Xell Zhang wrote: for ($i = 'A'; $i 'Z'; $i++) { echo $i . ' '; } Rather do it like this: for ($i = 65; $i 91; $i++) { echo chr($i) . ' '; } -- Regards, Clive. Real Time Travel Connections {No electrons were harmed in the creation, transmission or reading of this email. However, many

Re: [PHP] A very strange loop!

2007-07-09 Thread Xell Zhang
OK. I did test like this: $a = 'Z'; $b = $a; $b++; print 'b = abr /'; print 'b++br /'; if ($a $b) print 'a bbr /'; The output is funny:) Thanks all of you! I think clive's way is the best for me:) On 7/9/07, Chris [EMAIL PROTECTED] wrote: Xell Zhang wrote: Hello all, I met a very