标签:var_dump
$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;
相信有时候你会用到。数组$arr1转换成另一个数组$arr2
标签:var_dump
原文地址:http://jyb2014.blog.51cto.com/9155315/1590133