Array file operations
This post was last edited by lazygc520 on 2013-09-05 13:13:44
Known quantity Group A and array B
$a = Array (
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 2X15 ',
' Count ' = ' 0 ',
),
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 2z15 ',
' Count ' = ' 16 ',
),
);
$b = Array (
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 2X15 ',
' Count ' = ' 0 ',
),
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 2z15 ',
' Count ' = ' 32 ',
),
Array (
' Cust_no ' = ' 310f6 1va5a ',
' Lotno ' = ' 3528 ',
' Count ' = ' 80 ',
),
);
The result is that when array B and the Cust_no and Lotno are all the same, you are prompted to update the table SQL
Otherwise, insert Table SQL. How can I ask?
Share to:
------Solution--------------------
What conditions do you want to change?
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";
}