Why does this:
<?php
$a = array( 1, 2, 3 );
echo "First iteration:\n";
foreach ( $a as $b => &$c ) {
echo $c . "\n";
}
echo "\nSecond iteration:\n";
foreach ( $a as $b => $c ) {
echo $c . "\n";
}
Produce this:
First iteration:
1
2
3
Second iteration:
1
2
2
I'm expecting the second iteration to produce the same result as the first, shouldn't I?
Observe that the difference is "element by reference" in the first foreach.