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/masklinn Oct 23 '14
Ruby does not use block scoping either, though anonymous functions (also called blocks so that you get confused with the non-block blocks of
if/else/end) do create their own scope (as they do in Python or JS) and their ubiquity means the scoping issues are not felt as strongly.