RE: [PHP-DEV] foreach incompatibility

From: Date: Sat, 12 Aug 2000 19:55:46 +0000
Subject: RE: [PHP-DEV] foreach incompatibility
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-28719@lists.php.net to get a copy of this message
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 > > > > 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 > > >

« previous php.dev (#28719) next »