$arr1 = array (
‘0‘ => array (‘fid‘ => 1, ‘tid‘ => 1, ‘name‘ =>‘Name1‘ ),
‘1‘ => array (‘fid‘ => 1, ‘tid‘ => 2 , ‘name‘ =>‘Name2‘ ),
‘2‘ => array (‘fid‘ => 1, ‘tid‘ => 5 , ‘name‘ =>‘Name3‘ ),
‘3‘ => array (‘fid‘ => 1, ‘tid‘ => 7 , ‘name‘ =>‘Name4‘ ),
‘4‘ => array (‘fid‘ => 3, ‘tid‘ => 9, ‘name‘ =>‘Name5‘ )
);
foreach($arr1 as $k => $v){
$temp[$v[‘fid‘]][] = array(
‘tid‘ => $v[‘tid‘],
‘name‘ => $v[‘name‘],
);
}
foreach($temp as $v){
$arr2[] = $v;
}
var_dump($arr2);die;
时间: 2024-11-08 20:12:48