Re: [PHP4BETA] Trying to be elegant...
| From: | Zeev Suraski | Date: | Sun, 05 Mar 2000 22:20:51 +0000 |
| Subject: | Re: [PHP4BETA] Trying to be elegant... | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-11539@lists.php.net to get a copy of this message | ||
At 22:56 05/03/2000 , Johan Ekenberg wrote:
In the "elegant spirit of Perl", I tried to use the following code in PHP: ---- while (list(,$val) = each(array("a", "b", "c"))) { print "$val<BR>\n"; } ---- It didn't work. I had to assign the array to a variable and pass the variable to each(). Is there a way to write this in a more elegant, "Perl spirit" way in PHP? (This is obviously not a matter of high technical importance, but one of artistic and poetic freedom :-)foreach(array("a", "b", "c") as $val) { print "$val<BR>\n"; } (PHP 4.0 only) Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/