Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10308 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6668 invoked by uid 1010); 8 Jun 2004 09:17:16 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 6555 invoked by uid 1007); 8 Jun 2004 09:17:15 -0000 Message-ID: <20040608091715.6553.qmail@pb1.pair.com> To: internals@lists.php.net Date: Tue, 08 Jun 2004 11:17:14 +0200 User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 80.126.99.118 Subject: Confusing pointers in PHP 4 and 5 From: taco@procurios.nl (Taco van den Broek) While venus is crossing the sun I'm trying to model a tree using two arrays; one containing the structure of the tree and the other containing the data of the nodes. The second array also contains pointers to 'subtrees' of the first array. Anyway, I discovered a strange behavior when I dumped the tree before and after making the pointers. Example: array( 2 => 'foo' ) ); var_dump($tree); $b = &$tree[1]; var_dump($tree); ?> This code will output the following: array(1) { [1]=> array(1) { [2]=> string(3) "foo" } } array(1) { [1]=> &array(1) { [2]=> string(3) "foo" } } As you can see the original tree now contains a pointer, how can that be, I didn't change the original array!? So what I'd like to know is: Is this intended behavior, and if so: why does it work like this and would it make some operations impossible? Taco