NYCPHP Meetup

NYPHP.org

[nycphp-talk] Best way to copy array by value

Aaron Fischer agfische at email.smith.edu
Sun Feb 25 15:47:45 EST 2007


I need to copy an array by value, not by reference.  Is there a best  
way to do this?  Right now I found serialize/unserialize which seems  
to do the trick.

Python has a function called deepcopy:
http://docs.python.org/lib/module-copy.html

For Java, it appears you can use a handmade function or serialize/ 
unserialize:
http://java.sun.com/developer/JDCTechTips/2001/tt0410.html

PHP seems to be similar to Java, in that you can write a function  
yourself or use serialize/unserialize.  I haven't found a function  
like deepcopy.

Thoughts?

Thanks,

-Aaron




More information about the talk mailing list