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

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

Reply via email to