php怎么将二维数组键名相同的元素转为新的数组
1个回答
展开全部
$arr=array(
'0'=>array('a'=>'aa','b'=>'tt','c'=>'ff'),
'1'=>array('d'=>'aa','b'=>'cc','a'=>'4sa'),
'2'=>array('c'=>'ff','d'=>'hh','b'=>'dd'),
);
$arr2=array();
foreach($arr as $k=>$v){
foreach($v as $key=>$val){
$arr2[$key][]=$val;
}
}
'0'=>array('a'=>'aa','b'=>'tt','c'=>'ff'),
'1'=>array('d'=>'aa','b'=>'cc','a'=>'4sa'),
'2'=>array('c'=>'ff','d'=>'hh','b'=>'dd'),
);
$arr2=array();
foreach($arr as $k=>$v){
foreach($v as $key=>$val){
$arr2[$key][]=$val;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询