I'm not sure how to word it.
Take the following example.
<?
$arr = array('first','second','third', 'fourth');
foreach ($arr as $k=>&$n) {
$n = $n;
}
var_dump($arr);
>?
returns
array(4) {
[0]=>
string(5) "first"
[1]=>
string(6) "second"
[2]=>
string(5) "third"
[3]=>
&string(6) "fourth"
}
That makes total sense, why would anything change? Well, adding a second loop that doesn't even do anything is where I got lost.
<?
$arr = array('first','second','third', 'fourth');
foreach ($arr as $k=>&$n) {
$n = $n;
}
foreach ($arr as $k=>$n) {
;
}
var_dump($arr);
?>
returns
array(4) {
[0]=>
string(5) "first"
[1]=>
string(6) "second"
[2]=>
string(5) "third"
[3]=>
&string(5) "third"
}
The last value of the array has become the same as the second to last. Why?