ID: 41474 Updated by: [EMAIL PROTECTED] Reported By: tayloj1 at uk dot ibm dot com -Status: Open +Status: Wont fix Bug Type: Documentation problem PHP Version: Irrelevant New Comment:
Is has nothing to do with arrays - that's the way how assignment works even with normal variables. Previous Comments: ------------------------------------------------------------------------ [2007-05-23 12:09:14] tayloj1 at uk dot ibm dot com Description: ------------ Ref: http://uk.php.net/manual/en/language.types.array.php Current PHP manual says: "You should be aware that array assignment always involves value copying. It also means that the internal array pointer used by current() and similar functions is reset. You need to use the reference operator to copy an array by reference. " This statement can be misunderstood and should be clarified as follows: " You should be aware that array assignment <delete word 'always'> involves value copying. It also means that the internal array pointer used by current() and similar functions is reset. You need to use the reference operator to copy an array by reference. When the array is copied by value, elements in the array are copied by reference if they are already references. An element in an array will be a reference if it was created by a reference assignment or if a reference has been created to the element." Example: <?php $a = array (1,2) ; $b = &$a[0] ; // make $a[0] part of ref set $c = $a ; $a[0] = 3 ; $a[1] = 4 ; echo $c[0] ; // outputs 3 because $c[0] was copied by reference echo "\n" ; echo $c[1] ; // outputs 2 (not 4) because $c[1] was copied by value ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41474&edit=1