Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

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.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: