diff options
author | Nicolas BERNSTEIN <alexis211@gmail.com> | 2011-09-17 16:48:29 +0200 |
---|---|---|
committer | Nicolas BERNSTEIN <alexis211@gmail.com> | 2011-09-17 16:48:29 +0200 |
commit | d0060968b77c39bdf8abffb071c971c166b59edb (patch) | |
tree | 0be52e00a25bd298235a0cf916fb07496d3ab95f /tpl/general/inc_tree.php | |
download | Bits-d0060968b77c39bdf8abffb071c971c166b59edb.tar.gz Bits-d0060968b77c39bdf8abffb071c971c166b59edb.zip |
First commit.
Diffstat (limited to 'tpl/general/inc_tree.php')
-rw-r--r-- | tpl/general/inc_tree.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tpl/general/inc_tree.php b/tpl/general/inc_tree.php new file mode 100644 index 0000000..9b13d5a --- /dev/null +++ b/tpl/general/inc_tree.php @@ -0,0 +1,18 @@ +<?php +function tree_branch($tree, $id, $func) { + if (!isset($tree[$id])) return; + foreach($tree[$id] as $branch) { + echo '<p>'.$func($branch).'</p>'; + if (isset($tree[$branch['id']])) { + echo '<div class="tree_branch">'; + tree_branch($tree, $branch['id'], $func); + echo '</div>'; + } + } +} + +function tree($tree, $func) { + echo '<div class="tree_root">'; + tree_branch($tree, 0, $func); + echo '</div>'; +} |