Re: [PHP-DEV] foreach incompatibility From: waldschrott (waldschrott <email protected>)
Date: 08/12/00

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 <email protected> [mailto:chrisv <email protected>]
> > Sent: Saturday, August 12, 2000 12:55 PM
> > To: Peter Kocks
> > Cc: php-dev <email protected>
> > Subject: Re: [PHP-DEV] foreach incompatibility
> >
> >
> > > 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
> >
> >
> >
>
>

-- 
o----------0-¬---------O-·---¬----o---®-----o o    O   °       .
| http://www.kiffen.de | pRoteçt y0ur bRaín |0  O °     ¤  °        ·
0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ ° o © °   .  ·
| psychedelic experience |  gott <email protected>  | O   ° o           °
o-¬--o--0-----©-·--O-----o-----0-¤----------o  0 °  · °  .  ¤ ·

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>