News for hackers. Stuff that matters.
Re:What PHP 5.5 might look like by snorkel on Thursday July 12, 2012 @11:22AM (#4234939)
Conspicuously absent from PHP:

   array_copy()
... in order to copy-by-value on arrays containing references. Currently to do that you have to do a very fragile hack like this:

   $copy = array_flip(array_flip($original));
... which is vulnerable to key-value collisions ... or you have to write your own homebrew array copy-by-value function.
Re:What PHP 5.5 might look like by nieksand on Thursday July 12, 2012 @12:29PM (#4235343)
Still ugly, but at least it won't crap out if your data has duplicate values:

    $copy = array_map( function($v) { return $v; }, $original );
Re:What PHP 5.5 might look like by ircmaxell on Friday July 13, 2012 @11:25AM (#4240177)
Very simple.

Either:

    $copy = $original;
Or, if you must have a function,

    function array_copy(array $a) {
        return $a;
    }
Arrays use the normal copy-on-write semantics of PHP. They are not passed by reference or object handle...

The only potential issue is if the array contains references deeper in.

Re:What PHP 5.5 might look like by TazeTSchnitzel on Thursday July 12, 2012 @11:38AM (#4235074)
File a bug report :)
Re:What PHP 5.5 might look like by smsm42 on Friday July 13, 2012 @01:07AM (#4238322)
Better yet, file an RFC and a pull request.
Re:What PHP 5.5 might look like by TazeTSchnitzel on Friday July 13, 2012 @04:32AM (#4238847)
Yep. That's what I'm trying to do for something else :D