本帖最后由 lazygc520 于 2013-09-05 13:13:44 编辑
已知数组a和数组b
$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',
),
);
分享到:
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";
}