Categories_library::category_tree PHP Method

category_tree() public method

Get categories in an array
public category_tree ( $data = [], $id = 'cat_id', $parent = 'cat_parent' )
    public function category_tree($data = array(), $id = 'cat_id', $parent = 'cat_parent')
    {
        if (!is_array($data) or count($data) == 0) {
            return FALSE;
        }
        foreach ($data as $row) {
            // This assigns all the select fields to the array.
            foreach ($row as $key => $val) {
                $arr[$key] = $val;
            }
            $menu_array[$row[$id]] = $arr;
        }
        unset($arr);
        foreach ($menu_array as $key => $val) {
            if (0 == $val[$parent]) {
                $depth = 0;
                foreach ($val as $the_key => $the_val) {
                    $arr[$the_key] = $the_val;
                }
                $this->_categories[$key] = $arr;
                $this->_category_subtree($key, $menu_array, $depth);
            }
        }
    }