我有两个数组:
$array1 = array(
'currencies' => array(
'dollars' => array(80,120,75),
'euro' => array(25,35,10,85),
),
);
$array2 = array(
'currencies' => array(
'dollars' => array(25),
),
);
我希望结果是:
$result = array(
'currencies' => array(
'dollars' => array(80,120,75,25),
'euro' => array(25,35,10,85),
),
);
这可以巧妙地完成吗?我试过了array_merge,array_merge_recursively等。
答案 0 :(得分:5)
你是如何尝试array_merge_recursive的?因为这对我有用:
<?php
$array1 = array(
'currencies' => array(
'dollars' => array(80,120,75),
'euro' => array(25,35,10,85),
),
);
$array2 = array(
'currencies' => array(
'dollars' => array(25),
),
);
var_dump(array_merge_recursive($array1, $array2));