我有两个数组
$arr1 = [
['month' => 1],
['month' => 2],
['month' => 3],
['month' => 4]
];
$arr2 = [
['month' => 3, 'info' => 'Alpha'],
['month' => 4, 'info' => 'Beta']
];
我曾尝试array_merge与array_merge_recursive我的预期均未合并数组。
预期合并:
$arr3 = [
['month' => 1],
['month' => 2],
['month' => 3, 'info' => 'Alpha'],
['month' => 4, 'info' => 'Beta']
];
实际array_merge_recursive是:
$arr3 = array_merge_recursive($arr2, $arr1);
$arr3 = [
['month' => 3, 'info' => 'Alpha'],
['month' => 4, 'info' => 'Beta']
['month' => 1],
['month' => 2],
['month' => 3],
['month' => 4]
];
泛舟湖上清波郎朗
哔哔one