p_master::build_tree PHP 메소드

build_tree() 공개 메소드

Build true binary tree from given array Not in use
public build_tree ( &$modules, &$parents )
    function build_tree(&$modules, &$parents)
    {
        $tree = array();
        foreach ($modules as $row) {
            $branch =& $tree;
            if ($row['parent_id']) {
                // Go through the tree to find our branch
                $parent_tree = $parents[$row['module_id']];
                foreach ($parent_tree as $id => $value) {
                    if (!isset($branch[$id]) && isset($branch['child'])) {
                        $branch =& $branch['child'];
                    }
                    $branch =& $branch[$id];
                }
                $branch =& $branch['child'];
            }
            $branch[$row['module_id']] = $row;
            if (!isset($branch[$row['module_id']]['child'])) {
                $branch[$row['module_id']]['child'] = array();
            }
        }
        return $tree;
    }