note 54650 added to language.references.arent

From: Date: Mon, 11 Jul 2005 14:18:05 +0000
Subject: note 54650 added to language.references.arent
Groups: php.notes 
Request: Send a blank email to php-notes+get-91769@lists.php.net to get a copy of this message
Note references in array elements behave very much the same as pointers. The following seems to defy the simple definition of array assignment as copy-by-value: unset($a); unset($b); $a[1]=1; $a[2]=&$a[1]; $b=$a; $b[2]=7; print_r($a); Array ( [1] => 7 [2] => 7 ) print_r($b); Array ( [1] => 7 [2] => 7 ) - so array assignment is a very shallow copy-by-value, which preserves reference associations in any array elements. Oddly, I believe PHP lacks a deep array-copy-by-value function. ---- Manual Page -- http://www.php.net/manual/en/language.references.arent.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54650 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54650&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54650&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54650&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54650&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54650&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54650&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54650&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91769) next »