PHP Class Cml\Vendor\Tree

Show file Open project: linhecheng/cmlphp Class Usage Examples

Public Methods

Method Description
getChild ( array $list, integer $id ) : string | array 获取子集
getParent ( array $list, integer $id ) : string | array 获取父集
getTree ( array $list, integer $pid, integer $selectedId, string $str = "<option value='$id' $selected>$tempPrefix$name</option>", string $prefix = '|--', string $selectedString = 'selected' ) : string | array 获取树--返回格式化后的数据
getTreeNoFormat ( array &$list, integer $pid ) : string | array 获取树--返回数组
setConfig ( array $config = [] ) : mixed 修改配置

Method Details

getChild() public static method

获取子集
public static getChild ( array $list, integer $id ) : string | array
$list array 树的数组
$id integer 父类ID
return string | array

getParent() public static method

获取父集
public static getParent ( array $list, integer $id ) : string | array
$list array 树的数组
$id integer 子集ID
return string | array

getTree() public static method

获取树--返回格式化后的数据
public static getTree ( array $list, integer $pid, integer $selectedId, string $str = "<option value='$id' $selected>$tempPrefix$name</option>", string $prefix = '|--', string $selectedString = 'selected' ) : string | array
$list array 数据列表数组
$pid integer 初始化树时候,代表获取pid下的所有子集
$selectedId integer 选中的ID值
$str string 组装后的字串
$prefix string 前缀
$selectedString string 选中时的字串 如selected checked
return string | array

getTreeNoFormat() public static method

获取树--返回数组
public static getTreeNoFormat ( array &$list, integer $pid ) : string | array
$list array 数据列表数组
$pid integer 初始化树时候,代表获取pid下的所有子集
return string | array

setConfig() public static method

修改配置
public static setConfig ( array $config = [] ) : mixed
$config array ['pid'=>'', 'id' => '', 'name' =>'name']
return mixed