note 49474 deleted from language.types.array by betz

From: Date: Tue, 18 Oct 2005 06:41:17 +0000
Subject: note 49474 deleted from language.types.array by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-97146@lists.php.net to get a copy of this message
Note Submitter: jmarbas at hotmail dot com ---- response to Sir_Fred If you print out the two arrays you will see that they are different copies and $arr2 is not a reference to $arr1. If it were referenced then adding an element to $arr2 would also add an element to $arr1. Maybe Im not understanding your comments. Can you give us a sample code that shows = returns a reference? <?php $arr1 = array(2,3); $arr2 = $arr1; print_r($arr1); print_r($arr2); $arr2[] = 4; print_r($arr1); print_r($arr2); ?>

« previous php.notes (#97146) next »