// 无限分类 function cateSort($data, $fid = 0, $count = 0) { static $arr = []; foreach ($data as $k => $v) { if ($v['fid'] == $fid) { $v['count'] = $count; $arr[] = $v; unset($data['$k']); cateSort($data, $v['id'], $count + 1); } } return $arr; }
转载于:https://my.oschina.net/u/3853452/blog/1933933