Re: Create a hierarchical hash from flat source

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/06/2011, at 10:14 AM, Scott Baker wrote:

> 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 :(

You still need to pass the value by reference to assign_children(), so:
$new = &$leaf[$pid];
assign_children($pid,$list,&$new);
---
Simon Welsh
Admin of http://simon.geek.nz/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux