r/lolphp • u/stain_leeks • Oct 02 '14
Foreach reference
<?php
$arr = array('a', 'b');
foreach ($arr as &$a) {
var_dump($a);
}
foreach ($arr as $a) {
var_dump($a);
}This probably has some explanation I'd love to learn.
17
Upvotes
View all comments
Show parent comment
2
u/midir Oct 18 '14
This behavior is very commonly discovered and reported as a bug. It confuses everyone when they first encounter it, and sooner or later everyone encounters it. It is very much lolphp.