News for hackers. Stuff that matters.
Re:How PHP's foreach works by narcissus on Wednesday February 27, 2013 @09:15PM (#5296535)
I hear ya. In fact, I got burned by that problem enough times to make a test for it in my PHPCS 'coding standard'... which is basically a handful of standards that look for my stupid, repeated, coding errors :)
Re:How PHP's foreach works by function_seven on Wednesday February 27, 2013 @09:37PM (#5296609)
My own standard is this:

    foreach ($array as & $ref) {
        // Do something with $ref
    } unset ($ref);
i.e. put the `unset()` call on the same line as the closing brace, forever "welding" it to that block.