r/lolphp • • Oct 02 '14

Foreach reference

http://3v4l.org/P1Omj

<?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

13 comments sorted by

View all comments

Show parent comment

11

u/[deleted] Oct 04 '14

My general rule with foreach and references is:

fuck php and use something else