summaryrefslogtreecommitdiff
path: root/tpl/general/inc_tree.php
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/general/inc_tree.php')
-rw-r--r--tpl/general/inc_tree.php18
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>';
+}