Array(
[0] => Array
(
[skuid] => 121307256
[cmmdtyType] => 1
)
[1] => Array
(
[skuid] => 121347694
[cmmdtyType] => 1
)
),Array(
[0] => Array
(
[skuId] => 121307256
[price] => 103.10
[discountRate] =>
)
[1] => Array
(
[skuId] => 121347694
[price] => 2.00
[discountRate] =>
)
)2个数组,想合并成这样的,除了循环还有什么好方法吗?Array(
[0] => Array
(
[skuid] => 121307256
[cmmdtyType] => 1
[price] => 103.10
[discountRate] =>
)
[1] => Array
(
[skuid] => 121347694
[cmmdtyType] => 1
[price] => 2.00
[discountRate] =>
)
)
3 回答
幕布斯6054654
TA贡献1876条经验 获得超7个赞
$a = [
['skuid' => 123, 'cmmdtyType' => 1],
['skuid' => 345, 'cmmdtyType' => 2]
];
$b = [
['skuid' => 123, 'price' => 1, 'discountRate' => 2],
['skuid' => 345, 'price' => 1, 'discountRate' => 2],
];
$c = array_replace_recursive($a, $b);
dd($c);
冉冉说
TA贡献1877条经验 获得超1个赞
function my_array_merge($array1, $array2) {
$result = Array();
foreach($array1 as $key => &$value) {
$result[$key] = array_merge($value, $array2[$key]);
}
return $result;
}
- 3 回答
- 0 关注
- 409 浏览
添加回答
举报
0/150
提交
取消