2 arrays are added, one array is written to another
Known quantity Group A and array B:
Array A:
Array (
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 2X15 ',
' Part_count ' = ' 0 ',
),
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 2z25 ',
' Part_count ' = ' 5 ',
),
)
Array B:
Array (
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 2z15 ',
' Part_count ' = ' 100 ',
),
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 3115 ',
' Part_count ' = ' 28 ',
),
)
The result of array B is added to the array a, and the corresponding part_count of Cust_no,lotno is accumulated. Turns out to be such a result:
Array (
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 2X15 ',
' Part_count ' = ' 0 ',
),
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 2z15 ',
' Part_count ' = ' 105 ',
),
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 3115 ',
' Part_count ' = ' 28 ',
),
)
How do you do that? What array functions do I need to use? Thank you!
Share to:
------Solution--------------------
$t =array ();
foreach (Array_merge ($a, $b) as $v) {
if (!isset ($t [$v [' Cust_no ']. _ '. $v [' Lotno ']]) {