Closed 。这个问题需要细节或清晰度 。目前不接受答案。
php中如何合并n个数组我的意思是我怎样才能完成这样的工作:
array_merge(from : $result[0], to : $result[count($result)-1])
OR
array_merge_recursive(from: $result[0], to : $result[count($result) -1])
Where $result
是一个内部有多个数组的数组,如下所示:
$result = Array(
0 => array(),//associative array
1 => array(),//associative array
2 => array(),//associative array
3 => array()//associative array
)
我的结果是:
$result = Array(
0 => Array(
"name" => "Name",
"events" => 1,
"types" => 2
),
1 => Array(
"name" => "Name",
"events" => 1,
"types" => 3
),
2 => Array(
"name" => "Name",
"events" => 1,
"types" => 4
),
3 => Array(
"name" => "Name",
"events" => 2,
"types" => 2
),
4 => Array(
"name" => "Name",
"events" => 3,
"types" => 2
)
)
我需要的是
$result = Array(
"name" => "name",
"events" => array(1,2,3),
"types" => array(2,3,4)
)