according to the online refernce foreach() doesn't change the array pointer.
However the following code:
$fred = array(1,2,3,4,5,6);
foreach ($fred as $fred1)
{ foreach ($fred as $fred2)
echo "$fred1 : $fred2<br>";
};
returns:
1 : 1
1 : 2
1 : 3
1 : 4
1 : 5
1 : 6
and stops there, implying that the second foreach() is interfering with the
first.
I've got around this in my actual case by creating two arrays and adding to
the second as well as the first, but this won't always be as convenient. Is
this a known bug or is the manual wrong?
... by the way
$fred = array(1,2,3,4,5,6);
$fred2 = $fred;
foreach ($fred as $fred1)
{ foreach ($fred2 as $fred2)
echo "$fred1 : $fred2<br>";
};
... doesn't work either which would normally imply that $fred2 is a pointer
to $fred rather than a copy. Can this be the case?
I am using version 4.0.0
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]