summaryrefslogblamecommitdiff
path: root/tpl/general/inc_tree.php
blob: 9b13d5ae4bc60f2c175b6542c539c975309c6bd4 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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>';
}