对分类进行等级拆分unlimitedForLevel

发布时间:2015-12-10 11:48:09编辑:丝画阁阅读(443)

    public function unlimitedForLevel($cate, $name = 'child', $pid = 0) {
$arr = array();
foreach ($cate as $key => $v) {
//判断,如果$v['pid'] == $pid的则压入数组Child
if ($v['pid'] == $pid) {
//递归执行
$v[$name] = self::unlimitedForLevel($cate, $name, $v['id']);
$arr[] = $v;
}
}
return $arr;
}

关键字