无限级分类接口
传递一个pid字段递归即可
/** * 无限级分类 * @param $data * @param int $pid * @return array */ function getTree($data, $pid=0){ $arr = array(); foreach ($data as $key=>$value){ if ($value['pid'] == $pid){ $value['children'] = getTree($data,$value['id']); $arr[] = $value; } } return $arr; }