/**
* getTree无限递归函数
* @param $data
* @param $field_id
* @param $field_pid
* @param int $pid
* @return array
* @fillable 变量,保存子集数据
*/
public function getTree($data, $field_id, $field_pid, $pid = 0) {
$arr = array();
foreach ($data as $k=>$v) {
if ($v->$field_pid == $pid) {
$arr[$k] = $v;
$arr[$k]['fillable'] = self::getTree($data, $field_id, $field_pid, $v->$field_id );
}
}
return $arr;
}
Laravel框架 -- 分类无限递归
最新推荐文章于 2024-06-18 09:51:29 发布