public static function create_tree_recursiv array elements parentId br

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public static function create_tree_recursive(array $elements, $parentId = 0) {
$branch = array();
foreach ($elements as $element) {
if ($element['PARENT_ID'] == $parentId) {
$children = self::create_tree_recursive($elements, $element['ID']);
if ($children) {
$element['children'] = $children;
}
$branch[] = $element;
}
}
return $branch;
}