有阵列
$A =
Array
(
[0] => Array ([0] => aaa)
[1] => Array([0] => bbb)
[2] => Array([1] => ccc)
[3] => Array([1] => ddd)
)
$B = array();
chang_arr($A){
//TODO
}
将得到一个像这样的数组$ B
Array
(
[0] => Array ([0] => aaa
[1] => bbb
)
[1] => Array([0] => ccc
[1] => ddd
)
)
答案 0 :(得分:2)
function chang_arr($A){
$B = array();
foreach($A as $ar) {
foreach($ar as $k => $v) {
$B[$k][] = $v
}
}
return $B;
}
$B = chang_arr($A);