Re: Question on foreach()?

From: Date: Fri, 14 Jul 2000 09:43:46 +0000
Subject: Re: Question on foreach()?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-24514@lists.php.net to get a copy of this message
I'm just curious as to why it was decided to implement foreach as: foreach($array as $value) instead of foreach($array as $key)? It seems to me that the latter is the more logical, since $value is available as $array[$key], while there is no (AFAIK) easy way to obtain $key given $array and $value. I'm not complaining, just looking to understand.
I wondered about too, like I did list($key)=each($array) before foreach() was availbe, I´m now forced to assign the value too. Would be nice if we had foreach($array key $key) or something like this, foreach($array => $key) would not make sense... -- 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 ° · ° . ¤ ·

« previous php.dev (#24514) next »