Re: Create a hierarchical hash from flat source
| From: | Scott Baker | Date: | Wed, 22 Jun 2011 22:14:24 +0000 |
| Subject: | Re: Create a hierarchical hash from flat source | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-313662@lists.php.net to get a copy of this message | ||
On 06/22/2011 03:06 PM, Simon J Welsh wrote:
> On further inspection, that's not the problem at all. The problem's around
> assign_children($pid,$list,&$new);
>
> The previous line you defined $new with $new = $leaf[$pid], *copying* that node into $new. Thus
> the assign_children() call updates $new, but not $lead[$pid].
>
> You can fix this by either assigning $new by reference ($new =& $leaf[$pid]) or by passing
> a reference to $lead[$pid] to assign_children instead of $new.
I updated the code:
http://www.perturb.org/tmp/tree.txt
I still get the same output though. Only one level of depth :(
--
Scott Baker - Canby Telcom
System Administrator - RHCE - 503.266.8253