note 107132 deleted from language.references.whatdo by danbrown

From: Date: Tue, 10 Jan 2012 20:16:40 +0000
Subject: note 107132 deleted from language.references.whatdo by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185551@lists.php.net to get a copy of this message
Note Submitter: Hamal at example dot com ---- About elrah's examples Just like PHP manual says "the reference behavior of arrays is defined in an element-by-element basis". If make a little change on example two, which adding one more element in $arr3, we can see this statement clearer. // Example one $arr1 = array(1); echo "\nbefore:\n"; echo "\$arr1[0] == {$arr1[0]}\n"; echo "<br />"; $arr2 = $arr1; $arr2[0]++; echo "\nafter:\n"; echo "\$arr1[0] == {$arr1[0]}\n"; echo "\$arr2[0] == {$arr2[0]}\n"; echo "<br />"; // Example two $arr3 = array(1, 3); //Add $arr3[1] = 2 $a =& $arr3[0]; echo "\nbefore:\n"; echo "\$a == $a\n"; echo "\$arr3[0] == {$arr3[0]}\n"; echo "<br />"; $arr4 = $arr3; $arr4[0]++; $arr4[1]++; echo "\nafter:\n"; echo "\$a == $a\n"; //echo 2 echo "\$arr3[0] == {$arr3[0]}\n"; //echo 2 echo "\$arr4[0] == {$arr4[0]}\n"; //echo 2 echo "\$arr3[1] == {$arr3[1]}\n"; //echo 3 echo "\$arr4[1] == {$arr4[1]}\n"; //echo 4 This is about the structure of an array and a variable in PHP. If you are interested in what a PHP array really is, check the following article out: http://nikic.github.com/2011/12/12/How-big-are-PHP-arrays-really-Hint-BIG.html

« previous php.notes (#185551) next »