如何组合这两个数组,以使键保持不变,但值是通过算术确定的?
注意 - 根据我的示例,键可能并不总是在每个数组中排列:
$Array1 = ([4] => 100, [5] => 200, [6] => 100, [7] => 400 );
$Array2 = ([2] => 300, [5] => -100, [16] => -500, );
期望的输出:
$Array3 = ([2] => 300, [4] => 100, [5] => 100, [6] => 100, [7] => 400, [16] => -500);
编辑:改进数组以突出为什么“foreach”不起作用