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 9:53 AM, Scott Baker wrote:

> I have a bunch of records in a DB that look like
> 
> id | parent_id
> --------------
> 1  | 4
> 2  | 4
> 3  | 2
> 4  | 0
> 5  | 2
> 6  | 1
> 7  | 3
> 8  | 7
> 9  | 7
> 
> I want to build a big has that looks like:
> 
> 4 -> 1 -> 6
>  -> 2 -> 3 -> 7 -> 9
>       -> 5      -> 8
> 
> I'm like 90% of the way there, but I can't get my recursive assignment
> to work. Has anyone done this before that could offer some pointers?
> Here is my sample code thus far:
> 
> http://www.perturb.org/tmp/tree.txt
> 
> I can get one level of depth, but nothing more than that :(

I haven't looked that much into your code, but:
$children = find_children($id,$list);

$list is never defined.
---
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