Re: [PHP] Array to HTML List
- Date: Thu, 31 Mar 2016 12:50:33 +0100
- From: Lester Caine <lester@xxxxxxxxxxx>
- Subject: Re: [PHP] Array to HTML List
On 30/03/16 05:24, Kevin Waterson wrote:
> I need to get an array of data (comments) into a threaded HTML list.
> Not too sure how to go about this one.
> Maybe I need to build up some sort of tree and traverse it.
> Any ideas on the best way forward appreciated.
The key here is your 'path' value and how it is generated.
In my tree structures, this value is 'parent', where the top of the tree
is id=0 and build down from that.
Your id=1 and id=4 are top records. Traversing id=1, one has id=5 then
id=7 & 8 and finally 7 descends to 9 and 10.
You end up with a two dimensional array
Bit pushed for time at the moment, but I'm sure you can see that each
level just re-curses down until the elements have no children. You add
the wrapper for each parent level, and only add the comment when you hit
Lester Caine - G8HFL
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php