Re: foreach incompatibility
| From: | waldschrott | Date: | Sat, 12 Aug 2000 20:32:28 +0000 |
| Subject: | Re: foreach incompatibility | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-28721@lists.php.net to get a copy of this message | ||
Oh no, I think that´s the change Andi wanted to make. I personally do use array_keys() in foreach() too and did not know that that will be disallowed too.
Andi told about "obscure" code...
...?
Peter Kocks wrote:
No, no, no.... as the manual clearly states: foreach(array_expression as $value) statement since array_keys() returns an array, the code should work just fine. If it doesn't then the langauge has changed. Of course, this is a big problem for us as we have used the array_keys form all over the place in our code. --pk -----Original Message----- From: chrisv@b0rked.dhs.org [mailto:chrisv@b0rked.dhs.org] Sent: Saturday, August 12, 2000 12:55 PM To: Peter Kocks Cc: php-dev@lists.php.net Subject: Re: [PHP-DEV] foreach incompatibility-- o----------0-¬---------O-·---¬----o---®-----o o O ° . | http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ ° · 0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ ° o © ° . · | psychedelic experience | gott@kiffen.de | O ° o ° o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·The following snippet of code works fine in php-4.0.1pl2, but not in the current CVS. I'm hoping this is a bug, and not an evolution of the language. <?I'm not sure about that, but if I want the array keys, i'd personally use: $foo = array("a" => "b", "c" => "d", "e" => "f"); foreach ($foo as $i => $dummy) { echo "$i\n"; } Chris$foo = array("a"=>"b", "c"=>"d", "e"=>"f"); foreach (array_keys($foo) as $i) { echo "$i\n"; }?>