$result = $this->m_common->get_all('item_category', ['isrm'=>'0', 'display'=>'1'], '*', 'ordering desc'); //以id为key值 $item_categories = []; foreach ($result as $key => $value) { $item_categories[$value['id']] = $value; }
$this->_get_item_nesting_categories($item_category); /** * 获取部位分类信息 - 数组嵌套方式 * @return array */ protected function _get_item_nesting_categories($data = []) { $new_data = []; if ( !empty($data) ) { foreach($data as $k=> $v){ if(isset($data[$v['fid']])){ $data[$v['fid']]['child'][$k] = &$data[$k]; // sui($data); exit; }else{ $new_data[$k] = &$data[$k]; } } } return $new_data; }