note 49474 added to language.types.array
| From: | jmarbas at hotmail dot com | Date: | Sat, 29 Jan 2005 13:15:55 +0000 |
| Subject: | note 49474 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84155@lists.php.net to get a copy of this message | ||
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);
?>
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49474
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49474&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49474&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49474&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49474&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49474&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49474&report=yes
Search -- http://master.php.net/manage/user-notes.php