News for hackers. Stuff that matters.
Re:How PHP's foreach works by dools on Wednesday February 27, 2013 @08:39PM (#5296419)
A more "hair friendly" way to modify an array from within a foreach loop is to just use the array key:

    foreach($array as $key => $value)
    {
        if(someCondition($key))
            $array[$key] = someTransformation($value);
    }
or whatever - ie. just use the key to modify the original array directly. It's much easier to read and see what's happening (in my opinion anyway).

There are no comments on this comment yet.