- function category(&$data, $parentId=0)
- {
- $category = array();
- foreach ($data as $key=>$value)
- {
- if ($value['parentId'] == $parentId)
- {
- unset($data[$key]);
- $value['child'] = category($data, $value['id']);
- $category[] = $value;
- }
- }
- return $category;
- }
- //该片段来自于http://www.codesnippet.cn/detail/240120148638.html
来源: http://www.codesnippet.cn/detail/240120148638.html