Re: Tree-like structure in PHP?
| From: | Robin Vickery | Date: | Fri, 16 Nov 2007 09:36:29 +0000 |
| Subject: | Re: Tree-like structure in PHP? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-264674@lists.php.net to get a copy of this message | ||
On 16/11/2007, Paul van Haren <paul.vanharen@zonnet.nl> wrote:
> I'm trying to use arrays to implement a sort of data tree. For the code to
> work, it is essential that the nodes can be edited after they have become
> part of the tree. That would require that the array elements are pushed
> "by reference" rather than "by value".
>
> <?php
>
> $arr1 = array ();
> $arr2 = array ();
>
> array_push ($arr1, 1);
> array_push ($arr1, $arr2); // <-- the important line
array_push ($arr1, &$arr2);
or
$arr1[] =& $arr2;
-robin