php循环合并多个二维数组为一个
Array([0]=>Array([depart_id]=>1[is_delete]=>0[team]=>1[num1]=>0[team1]=>1[rq]=>周一[rqt...
Array
(
[0] => Array
(
[depart_id] => 1
[is_delete] => 0
[team] => 1
[num1] => 0
[team1] => 1
[rq] => 周一
[rqt] => 1
[team_count] => 4
)
[1] => Array
(
[depart_id] => 1
[is_delete] => 0
[team] => 2
[num2] => 0
[team2] => 2
[rq] => 周一
[rqt] => 1
[team_count] => 4
)
[2] => Array
(
[depart_id] => 1
[is_delete] => 0
[team] => 3
[num3] => 0
[team3] => 3
[rq] => 周一
[rqt] => 1
[team_count] => 4
)
[3] => Array
(
[depart_id] => 1
[is_delete] => 0
[team] => 4
[num4] => 0
[team4] => 4
[rq] => 周一
[rqt] => 1
[team_count] => 4
)
}
将这个数组合并成一个数组,求大神写代码 展开
(
[0] => Array
(
[depart_id] => 1
[is_delete] => 0
[team] => 1
[num1] => 0
[team1] => 1
[rq] => 周一
[rqt] => 1
[team_count] => 4
)
[1] => Array
(
[depart_id] => 1
[is_delete] => 0
[team] => 2
[num2] => 0
[team2] => 2
[rq] => 周一
[rqt] => 1
[team_count] => 4
)
[2] => Array
(
[depart_id] => 1
[is_delete] => 0
[team] => 3
[num3] => 0
[team3] => 3
[rq] => 周一
[rqt] => 1
[team_count] => 4
)
[3] => Array
(
[depart_id] => 1
[is_delete] => 0
[team] => 4
[num4] => 0
[team4] => 4
[rq] => 周一
[rqt] => 1
[team_count] => 4
)
}
将这个数组合并成一个数组,求大神写代码 展开
展开全部
PHP 中的 array_merge_recursive() 函数可以实现
将一个或多个数组的元素的合并起来,一个数组中的值附加在前一个数组的后面。并返回作为结果的数组。
当有重复的键名时,值不会被覆盖,而是将多个相同键名的值递归组成一个数组。
array_merge_recursive(array1,array2,array3...)
参数说明
array1 必需。输入的第一个数组。
array2 必需。输入的第二个数组。
array3 可选。可指定的多个输入数组。
例如:
<?php
$a1=array("a"=>"Horse","b"=>"Dog");
$a2=array("c"=>"Cow","b"=>"Cat");
print_r(array_merge_recursive($a1,$a2));
?>
输出:
Array (
[a] => Horse
[b] => Array ( [0] => Dog [1] => Cat )
[c] => Cow
)
注:array_merge() 函数也可以实现,与 array_merge_recursive()函数不同是,如果键名有重复,该键的键值为最后一个键名对应的值(后面的覆盖前面的)。如果数组是数字索引的,则键名会以连续方式重新索引。
将一个或多个数组的元素的合并起来,一个数组中的值附加在前一个数组的后面。并返回作为结果的数组。
当有重复的键名时,值不会被覆盖,而是将多个相同键名的值递归组成一个数组。
array_merge_recursive(array1,array2,array3...)
参数说明
array1 必需。输入的第一个数组。
array2 必需。输入的第二个数组。
array3 可选。可指定的多个输入数组。
例如:
<?php
$a1=array("a"=>"Horse","b"=>"Dog");
$a2=array("c"=>"Cow","b"=>"Cat");
print_r(array_merge_recursive($a1,$a2));
?>
输出:
Array (
[a] => Horse
[b] => Array ( [0] => Dog [1] => Cat )
[c] => Cow
)
注:array_merge() 函数也可以实现,与 array_merge_recursive()函数不同是,如果键名有重复,该键的键值为最后一个键名对应的值(后面的覆盖前面的)。如果数组是数字索引的,则键名会以连续方式重新索引。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询