note 50036 added to language.types.array

From: Date: Wed, 16 Feb 2005 08:59:40 +0000
Subject: note 50036 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-85099@lists.php.net to get a copy of this message
On array copying a deep copy is done of elements except those elements which are references, in which case the reference is maintained. This is a very important thing to understand if you intend on mixing references and recursive arrays. By Example: $a = array( 1 ); $aref_a = array( &$a ); $copy_aref_a = $aref_a; $acopy_a = array( $a ); $copy_acopy_a = $acopy_a; $a[] = 5; $acopy_a[0][] = 6; print_r( $aref_a ); //Shows: ( (1,5) ) print_r( $copy_aref_a ); //Shows: ( (1,5) ) print_r( $acopy_a ); //Shows: ( (1, 6) ) print_r( $copy_acopy_a ); //Shows: ( (1) ) ---- Manual Page -- http://www.php.net/manual/en/language.types.array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50036 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50036&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50036&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50036&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50036&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50036&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50036&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85099) next »