PHP TP5 实现规格数据排列
public function spec($spec){ $res=[]; foreach ($spec as $item){ $res[$item['spec_id']]=[ 'spec_id'=>$item['spec_id'], 'spec_name'=>$item['spec_name'], 'spec_values'=>[] ]; } foreach ($spec as $item){ $res[$item['spec_id']]['spec_values'][$item['id']]=$item['spec_value']; } return $res; }