主要是array_reduce()函数 $country_arr = M('my_sell_goods')-field(array('id','product_name','product_type'))-select();$newArray = array_reduce($country_arr,function($newArray,$v){ $newArray[$v['id']] = array('product_name'=$v['produ
$country_arr = M('my_sell_goods')->field(array('id','product_name','product_type'))->select(); $newArray = array_reduce($country_arr,function(&$newArray,$v){ $newArray[$v['id']] = array('product_name'=>$v['product_name'],'product_type'=>$v['product_type']); return $newArray; }); $country_arr = $newArray; print_r($country_arr);