我需要把三维阵列与两维阵组合合并起来,其基础是共同的补贴。
在下文中,“乔治·华盛顿”有1名助理。 我需要评估他的价值,这在第二个阵列中,也有1个。
“约翰·阿达姆斯”为2,这在第二阵列中没有。 因此,必须将他的价值定为0(或NUL)。
最终结果是三维阵列,其价值已加到原阵列的每一项目。
www.un.org/Depts/DGACM/index_spanish.htm Array #1
Array
(
[0] => Array
(
[0] => Array
(
[id] => 1
[name] => "George Washington"
)
[total] => 8
[average] => 2.5
)
[1] => Array
(
[0] => Array
(
[id] => 2
[name] => "John Adams"
)
[total] => 6
[average] => 3.0
)
[2] => Array
(
[0] => Array
(
[id] => 5
[name] => "James Monroe"
)
[total] => 9
[average] => 2.0
)
)
<>12>
Array
(
[0] => Array
(
[id] => 1
[value] => 12
)
[1] => Array
(
[id] => 5
[value] => 18
)
)
<<>Desired Result:
Array
(
[0] => Array
(
[0] => Array
(
[id] => 1
[name] => "George Washington"
)
[total] => 8
[average] => 2.5
[value] => 12
)
[1] => Array
(
[0] => Array
(
[id] => 2
[name] => "John Adams"
)
[total] => 6
[average] => 3.0
[value] => 0
)
[2] => Array
(
[0] => Array
(
[id] => 5
[name] => "James Monroe"
)
[total] => 9
[average] => 2.0
[value] => 18
)
)
www.un.org/Depts/DGACM/index_spanish.htm 我迄今所尝试的内容:。
我把所有补贴价值从头几个阵列分离成一个新阵列,称为ids。 然后,在通过第二阵列的物品时,我检查一下,第二阵列的补贴是否出现在女兵阵列中。
But then I m stuck because I don t know how to specify which item in the first array needs to receive the new value . Also, this seems like a messy solution because of the overhead involved in creating the $ids array.