View Single Post

  #3 (permalink)  
Old 11-16-2007
Robin Vickery
 
Posts: n/a
Default Re: [PHP] Tree-like structure in PHP?

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
Reply With Quote