需要帮助以使用两个数组制作新数组。 一个数组是
array:2 [▼
"Date Date 2018-07-23" => array:1 [▼
6 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
]
"Date Date 2018-07-28" => array:3 [▼
1 => array:2 [▼
"avg" => 0.031472222222222
"line_n0" => 1
]
4 => array:2 [▼
"avg" => 0.011111111111111
"line_n0" => 4
]
5 => array:2 [▼
"avg" => 0.011111111111111
"line_n0" => 5
]
]
]
另一个数组是
array:6 [▼
1 => array:2 [▼
"avg" => 0
"line_n0" => 1
]
2 => array:2 [▼
"avg" => 0
"line_n0" => 2
]
3 => array:2 [▼
"avg" => 0
"line_n0" => 3
]
4 => array:2 [▼
"avg" => 0
"line_n0" => 4
]
5 => array:2 [▼
"avg" => 0
"line_n0" => 5
]
6 => array:2 [▼
"avg" => 0
"line_n0" => 6
]
array:2 [▼
"Date Date 2018-07-23" => array:1 [▼
1 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
2 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
3 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
4 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
5 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
6 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
]
"Date Date 2018-07-28" => array:3 [▼
1 => array:2 [▼
"avg" => 0.031472222222222
"line_n0" => 1
]
2 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
3 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
4 => array:2 [▼
"avg" => 0.011111111111111
"line_n0" => 4
]
5 => array:2 [▼
"avg" => 0.011111111111111
"line_n0" => 5
]
6 => array:2 [▼
"avg" => 0.0
"line_n0" => 6
]
]
]
请帮助我如何组合数组,如果没有第一个数组key的帮助,我想推送第二个数组元素。我尝试但不清楚制作新数组。我已经尝试了数组合并和数组合并,但是不清楚是否可以创建这个新数组。
答案 0 :(得分:0)
使用下面的array_merge()函数示例
<?php
$array1 = array("color" => "red", 2, 4);
$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
$result = array_merge($array1, $array2);
print_r($result);
?>
输出如下:
Array
(
[color] => green
[0] => 2
[1] => 4
[2] => a
[3] => b
[shape] => trapezoid
[4] => 4
)