下面的2個數組在2015年沒有像他們應該合併的那樣合併。相反,它會像上一個例子一樣創建[2016]。Array_merge_recursive沒有正確合併(php)
代碼我使用:
$合併= array_merge_recursive($陣列,$電流);
第一陣列:($電流)
Array
(
[Particulier] => Array
(
[Weekend] => Array
(
[2015] => Array
(
[06] => Array
(
[0] => Array
(
[id] => 111
[startDate] => 12-06-2015
[endDate] => 15-06-2015
[price] => 920
)
)
)
)
)
)
第二陣列:($陣列)
Array
(
[Particulier] => Array
(
[Weekend] => Array
(
[2015] => Array
(
[05] => Array
(
[0] => Array
(
[id] => 90
[startDate] => 01-05-2015
[endDate] => 04-05-2015
[price] => 920
)
[1] => Array
(
[id] => 91
[startDate] => 08-05-2015
[endDate] => 11-05-2015
[price] => 920
)
[2] => Array
(
[id] => 92
[startDate] => 15-05-2015
[endDate] => 18-05-2015
[price] => 920
)
)
[06] => Array
(
[0] => Array
(
[id] => 112
[startDate] => 19-06-2015
[endDate] => 22-06-2015
[price] => 920
)
)
)
)
[Midweek] => Array
(
[2015] => Array
(
[05] => Array
(
[0] => Array
(
[id] => 94
[startDate] => 11-05-2015
[endDate] => 15-05-2015
[price] => 1225
)
[1] => Array
(
[id] => 95
[startDate] => 18-05-2015
[endDate] => 22-05-2015
[price] => 1225
)
)
[06] => Array
(
[0] => Array
(
[id] => 118
[startDate] => 15-06-2015
[endDate] => 19-06-2015
[price] => 1225
)
)
)
)
)
[Clienten en patienten] => Array
(
[Weekend] => Array
(
[2015] => Array
(
[05] => Array
(
[0] => Array
(
[id] => 105
[startDate] => 01-05-2015
[endDate] => 04-05-2015
[price] => 645
)
)
)
)
)
)
當前的結果:($合併)
Array
(
[Particulier] => Array
(
[Weekend] => Array
(
[2015] => Array
(
[05] => Array
(
[0] => Array
(
[id] => 90
[startDate] => 01-05-2015
[endDate] => 04-05-2015
[price] => 920
)
[1] => Array
(
[id] => 91
[startDate] => 08-05-2015
[endDate] => 11-05-2015
[price] => 920
)
[2] => Array
(
[id] => 92
[startDate] => 15-05-2015
[endDate] => 18-05-2015
[price] => 920
)
)
[06] => Array
(
[0] => Array
(
[id] => 112
[startDate] => 19-06-2015
[endDate] => 22-06-2015
[price] => 920
)
)
)
[2016] => Array
(
[06] => Array
(
[0] => Array
(
[id] => 111
[startDate] => 12-06-2015
[endDate] => 15-06-2015
[price] => 920
)
)
)
)
編輯:預期的結果
Array
(
[Particulier] => Array
(
[Weekend] => Array
(
[2015] => Array
(
[05] => Array
(
[0] => Array
(
[id] => 90
[startDate] => 01-05-2015
[endDate] => 04-05-2015
[price] => 920
)
[1] => Array
(
[id] => 91
[startDate] => 08-05-2015
[endDate] => 11-05-2015
[price] => 920
)
[2] => Array
(
[id] => 92
[startDate] => 15-05-2015
[endDate] => 18-05-2015
[price] => 920
)
)
[06] => Array
(
[0] => Array
(
[id] => 112
[startDate] => 19-06-2015
[endDate] => 22-06-2015
[price] => 920
)
[1] => Array
(
[id] => 111
[startDate] => 12-06-2015
[endDate] => 15-06-2015
[price] => 920
)
)
)
)
如果需要任何其他信息,請諮詢! 在此先感謝!
預期的結果嗎? –
@anantkumarsingh已添加! – Hees1989