At the end of this post, lazygc520 is used to edit the known arrays a and B $ a & nbsp; array & nbsp; from 2013-09-0513: 13: 44; (& nbsp; 0 & nbsp; & gt; & nbsp; array & nbsp; (& nbsp; cust _ array file operations
This post was last edited by lazygc520 at 13:13:44
Array a and array B are known
$a = array (
0 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2X15',
'count' => '0',
),
1 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2Z15',
'count' => '16',
),
);
$b = array (
0 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2X15',
'count' => '0',
),
1 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2Z15',
'count' => '32',
),
2 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '3528',
'count' => '80',
),
);
The expected result is that when both cust_no and lotno of array B and array a are the same, the system prompts update table SQL
Otherwise, insert table SQL. How can this problem be solved?
Share :??? Array? (???? 'Cust _ no '? =>? '310f6? 1VA5A ',???? 'Lotno '? =>? '2x15... 'data-pics = ''>
------ Solution --------------------
What conditions should I modify?
foreach($b as $i=>$v) {
print_r($v);
if(isset($a[$i]) && $v['cust_no'] == $a[$i]['cust_no'] && $v['lotno'] == $a[$i]['lotno']) {
echo "update table sql\n";
}else echo "insert table sql\n";
}