Add two arrays and write an array to the known arrays a and B: // array a: array & nbsp; (& nbsp; 0 & nbsp; = & gt; & nbsp; array & nbsp; (& nbsp; & add two arrays to add one array to another
Known arrays a and B:
// Array:
Array (
0 =>
Array (
'Cust _ no' => '310f6 1VA5A ',
'Lotno' => '2x15 ',
'Part _ count' => '0 ',
),
1 =>
Array (
'Cust _ no' => '310f6 1VA5A ',
'Lotno' => '2z25 ',
'Part _ count' => '5 ',
),
)
// Array B:
Array (
0 =>
Array (
'Cust _ no' => '310f6 1VA5A ',
'Lotno' => '2z15 ',
'Part _ count' => '123 ',
),
1 =>
Array (
'Cust _ no' => '310f6 1VA5A ',
'Lotno' => '123 ',
'Part _ count' => '28 ',
),
)
Add the result of array B to array a, and accumulate the part_count corresponding to cust_no and lotno. The result is as follows:
array (
0 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2X15',
'part_count' => '0',
),
1 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2Z15',
'part_count' => '105',
),
2 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '3115',
'part_count' => '28',
),
)
How can this be done? What array functions are required? Thank you! Share :??? Array? (???? 'Cust _ no '? =>? '310f6? 1VA5A ',???? 'Lotno '? =>? '2... 'data-pics = ''>
------ Solution --------------------
$t=array();
foreach(array_merge($a,$b) as $v){
if(!isset($t[$v['cust_no'].'_'.$v['lotno']])){