我有两个具有相同键的多维数组。我想将这些数组合并为一个。
$sourceData = $array1;
$sourceDataN = $array2;
foreach ($sourceData as $keySd => $sd){
foreach ($sourceDataN as $keySdn => $sdn){
if($keySd == $keySdn){
foreach ($sd as $keySdd => $sdd ){
foreach ($sdn as $keySdnn => $sdnn ){
if($keySdd == $keySdnn){
$new[$keySd][] = array_merge($sdd, $sdnn);
}
}
}
}
}
}
Array (
[809] => Array
(
[ss] => Array
(
[qty] => 0
)
[bh] => Array
(
[qty] => 14
)
[li] => Array
(
[qty] => 0
)
[mg] => Array
(
[qty] => 0
)
)
[1944] => Array
(
[ss] => Array
(
[qty] => 25
)
[bh] => Array
(
[qty] => 10
)
[za] => Array
(
[qty] => 10
)
[li] => Array
(
[qty] => 39
)
[mg] => Array
(
[qty] => 0
)
)
)
Array (
[809] => Array
(
[ss] => Array
(
[price] => 603.07
)
[bh] => Array
(
[price] => 649.95
)
[li] => Array
(
[price] => 628.48
)
[mg] => Array
(
[price] => 629
)
)
[1944] => Array
(
[ss] => Array
(
[price] => 848.7
)
[bh] => Array
(
[price] => 883.74
)
慕姐4208626