我有两个不同的数组如何得到低于输出。 数组一: -
[81799] => Array
(
[TOTAL_HITS] => 254
[UNIQUE_HITS] => 82
)
阵列二: -
[81799] => Array
(
[ACTIVATION] => 7561.60
[RENEWAL] => 300
[ACT_REVENUE] => 7310.22
)
预期产出: -
[81799] => Array
(
[TOTAL_HITS] => 254
[UNIQUE_HITS] => 82
[ACTIVATION] => 7561.60
[RENEWAL] => 300
[ACT_REVENUE] => 7310.22
)
答案 0 :(得分:1)
这应该可以解决问题。
我想你的数组如下所示:
<?php
$a1 = array("81799" => array("TOTAL_HITS" => 254, "UNIQUE_HITS" => 82));
$a2 = array("81799" => array("ACTIVATION" => 7561.60, "RENEWAL" => 300, "ACT_REVENUE" => 7310.22));
foreach($a1 as $key => $val) {
$result[$key] = array_merge($a1[$key], $a2[$key]);
}
print_r($result);
答案 1 :(得分:1)
试试这个,
$a = array("81799" => Array
(
"TOTAL_HITS" => 254,
"UNIQUE_HITS" => 82
)
);
$b = array("81799" => Array
(
"ACTIVATION" => 7561.60,
"RENEWAL" => 300,
"ACT_REVENUE" => 7310.22
)
);
foreach($a as $key_a => $val_a)
{
$temp = $b[$key_a] + $val_a;
//$result[$key_a] = $b[$key_a];
$result[$key_a] = $temp;
}
<强> DEMO 强>