PHP 4.0 Bug #5270: Nested foreach() using a copy of the same array does not work properly.

From: Date: Thu, 29 Jun 2000 19:17:45 +0000
Subject: PHP 4.0 Bug #5270: Nested foreach() using a copy of the same array does not work properly.
Groups: php.dev 
Request: Send a blank email to php-dev+get-22668@lists.php.net to get a copy of this message
From: danbeck@dealnews.com Operating system: Redhat 6.1 PHP version: 4.0 Latest CVS (29/06/2000) PHP Bug Type: Scripting Engine problem Bug 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.

« previous php.dev (#22668) next »