Re: PHP 4.0 Bug #5270: Nested foreach() using a copy of the same array does not work properly.
| From: | waldschrott | Date: | Wed, 28 Jun 2000 20:37:13 +0000 |
| Subject: | Re: PHP 4.0 Bug #5270: Nested foreach() using a copy of the same array does not work properly. | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-22670@lists.php.net to get a copy of this message | ||
I´d posted a similar bug (the same bug(?)) before, but I could not find that damn bug report again, you don´t need to copy $test, it works (bugs) too if both statements work on $test...
summary: php seems to go wrong too if it´s the same variable
danbeck@dealnews.com wrote:
-- 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 ° · ° . ¤ ·From: danbeck@dealnews.comOperating system: Redhat 6.1PHP version: 4.0 Latest CVS (29/06/2000) PHP Bug Type: Scripting Engine problemBug description: Nested foreach() using a copy of the same array does not work properly. The following code does not work properly. $test = $test2 = array (0,1,2,3,4,5,6,7,8,9); foreach($test as $a) { foreach($test2 as $b) { echo "$a : $b\n"; } } The first foreach() only happens once. I understand that foreach() will reset the array pointer but why does using the copy also seem to do the same thing to the original array? Shouldn't a copy be just that.. a copy? It seems that it's more of a reference than anything.