Request for comment

From: Date: Thu, 10 Aug 2000 22:13:22 +0000
Subject: Request for comment
Groups: php.dev 
Request: Send a blank email to php-dev+get-28513@lists.php.net to get a copy of this message
Hi, I just fixed a problem with foreach() which has been open a long time. <? $a = array("A" => "a", "B" => "b"); $b = $a; foreach($a as $ka => $va) { echo "$ka - $va\n"; foreach($b as $kb => $vb) { echo "$kb - $vb\n"; } } ?> What happened here is that $b was effected by the traversing of $a where it shouldn't have. I have fixed this. What also works is foreach(array(1,2,3 as $ka => $va) The main problem is with weird expressions in foreach such as foreach($a=$b) which would still have such side effect issues. I think this code is obscure and the change of people using it is slim. I would like to change foreach to only support: a) foreach($var) where var could be any variable/multi-dimensionaly variable ($a[0]). b) foreach(array(....)) Does anyone see a problem with this? It would mean you can't put obscure stuff into foreach(). Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/

« previous php.dev (#28513) next »