Cml\Vendor\Tree::getParent PHP Method

getParent() public static method

获取父集
public static getParent ( array $list, integer $id ) : string | array
$list array 树的数组
$id integer 子集ID
return string | array
    public static function getParent($list, $id)
    {
        if (!is_array($list)) {
            return [];
        }
        $temp = [];
        foreach ($list as $v) {
            $temp[$v[self::$config['id']]] = $v;
        }
        $parentid = $temp[$id][self::$config['pid']];
        return $temp[$parentid];
    }