Re: foreach incompatibility
| From: | chrisv at b0rked dot dhs dot org | Date: | Sat, 12 Aug 2000 19:54:38 +0000 |
| Subject: | Re: foreach incompatibility | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-28718@lists.php.net to get a copy of this message | ||
> 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.
>
> <?
>
> $foo = array("a"=>"b", "c"=>"d",
> "e"=>"f");
> foreach (array_keys($foo) as $i) {
> echo "$i\n";
> }
>
> ?>
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