Daniel Convissor danielc-at-analysisandsolutions.com |nyphp dev/internal group use| wrote:

Aaron:

On Sun, Feb 25, 2007 at 03:47:45PM -0500, Aaron Fischer wrote:
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.

What ARE you talking about? Copying by value is the default behavior in PHP.


INPUT:
$a1 = array('a', 'b');
$a2 = $a1;
$a1[0] = 'changed';
print_r($a1);
print_r($a2);


OUTPUT:
Array
(
   [0] => changed
   [1] => b
)
Array
(
   [0] => a
   [1] => b
)


--Dan

That Dan's just a straight shooter with management written all over him ;-)


_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to