Re: [PHP] print a to z
paragasu schreef: i have this cute little problem. sounds more like a homework assignment. by now you know range(), by all means have array_map() too: array_map(print_r, range(a,z)); i want to print a to z for site navigation my first attempt work fine for($i = '65'; $i '91'; ++$i) echo chr($i); but someone point me a more interesting solutions for($i = 'a'; $i 'z'; ++$i) echo $i the only problem with the 2nd solutions is it only print up to Y without z. so how to print up to z with the 2nd solutions? because it turn out that you cant to something like for($i = 'a'; $i = 'z'; ++$i).. STFA - Rasmus Lerdorf has explained exactly why this works the way it does more than once IIRC. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] print a to z
i have this cute little problem. i want to print a to z for site navigation my first attempt work fine for($i = '65'; $i '91'; ++$i) echo chr($i); but someone point me a more interesting solutions for($i = 'a'; $i 'z'; ++$i) echo $i the only problem with the 2nd solutions is it only print up to Y without z. so how to print up to z with the 2nd solutions? because it turn out that you cant to something like for($i = 'a'; $i = 'z'; ++$i).. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] print a to z
paragasu wrote: i have this cute little problem. i want to print a to z for site navigation my first attempt work fine for($i = '65'; $i '91'; ++$i) echo chr($i); but someone point me a more interesting solutions $letters = range('a', 'z'); foreach ($letters as $letter) { echo $letter; } -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] print a to z
$letters = range('a', 'z'); foreach ($letters as $letter) { echo $letter; } wow.. that is a very nice solutions you give me chris. thanks On 1/15/09, Chris dmag...@gmail.com wrote: paragasu wrote: i have this cute little problem. i want to print a to z for site navigation my first attempt work fine for($i = '65'; $i '91'; ++$i) echo chr($i); but someone point me a more interesting solutions $letters = range('a', 'z'); foreach ($letters as $letter) { echo $letter; } -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] print a to z
On Thu, Jan 15, 2009 at 08:32:14PM -0800, paragasu wrote: i have this cute little problem. i want to print a to z for site navigation my first attempt work fine for($i = '65'; $i '91'; ++$i) echo chr($i); but someone point me a more interesting solutions for($i = 'a'; $i 'z'; ++$i) echo $i the only problem with the 2nd solutions is it only print up to Y without z. so how to print up to z with the 2nd solutions? because it turn out that you cant to something like for($i = 'a'; $i = 'z'; ++$i).. for ($i = 'a'; $i = 'z'; $i++) echo $i; Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] print a to z
I used that notation before, and it did not work 100%. Adapt as follows: for ($i = 'a'; $i = 'z'; $i++) if ($i == aa) break; else echo $i; -Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: 16 January 2009 07:55 AM To: php-general@lists.php.net Subject: Re: [PHP] print a to z On Thu, Jan 15, 2009 at 08:32:14PM -0800, paragasu wrote: i have this cute little problem. i want to print a to z for site navigation my first attempt work fine for($i = '65'; $i '91'; ++$i) echo chr($i); but someone point me a more interesting solutions for($i = 'a'; $i 'z'; ++$i) echo $i the only problem with the 2nd solutions is it only print up to Y without z. so how to print up to z with the 2nd solutions? because it turn out that you cant to something like for($i = 'a'; $i = 'z'; ++$i).. for ($i = 'a'; $i = 'z'; $i++) echo $i; Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] print a to z
2009/1/15 Leon du Plessis l...@dsgnit.com: I used that notation before, and it did not work 100%. Adapt as follows: for ($i = 'a'; $i = 'z'; $i++) if ($i == aa) break; else echo $i; It's weird, but true--the simple '=' breaks the loop. However, in the above example, you don't need the 'else'; the 'break' ensures that the 'echo $i'; will not execute. You can step around the the problem more elegantly: for ($i = 'a'; $i !== 'aa'; $i++) { echo $i; } Regards, Torben -Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: 16 January 2009 07:55 AM To: php-general@lists.php.net Subject: Re: [PHP] print a to z On Thu, Jan 15, 2009 at 08:32:14PM -0800, paragasu wrote: i have this cute little problem. i want to print a to z for site navigation my first attempt work fine for($i = '65'; $i '91'; ++$i) echo chr($i); but someone point me a more interesting solutions for($i = 'a'; $i 'z'; ++$i) echo $i the only problem with the 2nd solutions is it only print up to Y without z. so how to print up to z with the 2nd solutions? because it turn out that you cant to something like for($i = 'a'; $i = 'z'; ++$i).. for ($i = 'a'; $i = 'z'; $i++) echo $i; Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] print a to z
This one time, at band camp, Leon du Plessis l...@dsgnit.com wrote: I used that notation before, and it did not work 100%. Adapt as follows: for ($i = 'a'; $i = 'z'; $i++) if ($i == aa) break; else echo $i; foreach(range('a', 'z') as $letter ) { echo $letter; } Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php