Hi everyone,
Last Friday I struggled for a long time with displaying some data that's stored using the Modified Preorder Tree Traversal method. Without making this email overly long and complicated (like my first draft was) I'd like to simply ask if someone has any links or functions or instructions they can give me on how to display my data in such a way.
I want the following:
Level 1A |--Level 2A | \--Level 3A | |--Level 4A | | \--Level 5A | \--Level 3B |--Level 2B | \--Level 3C \--Level 2C \--Level 3D
What I always end up with is this (or some variant of it):
Level 1A |--Level 2A | \--Level 3A | | |--Level 4A | | | \--Level 5A | | \--Level 3B |--Level 2B | \--Level 3C \--Level 2C | \--Level 3D
Any help is appreciated.
Chris.
hi chris,
just some thoughts:
i assume you build your tree from leaves to root via recursive functions? if so you need a logic like this:
<?php
function isLastChild($self, $parent) { // check, whether $self is the last child of parent // return true or false }
if (!isLastChild($parent, $grandparent)) { // draw your vertical line symbol } else { // draw just a spaceholder } // following draw the label of $self
?>
hope you understand, what i mean?
hth SVEN
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php