I cannot compare the values of this array
$products = [];
foreach (array_keys($match[2]) as $idx)
{
$tagliaprodotto = rtrim(substr($match[2][$idx],1));
$tagliaquantita = ltrim($match[3][$idx],'0');
$products[] = [
'product' => $tagliaprodotto,
'quantity' => $tagliaquantita,
'terminal' => $match[4][$idx]
];
}
With the values inside the database! Should I do that?
I would like to compare the elements that I have inside the database with array's value and make some if as:
-If product is not present in the database:
INSERT INTO table (product, quantity, terminal, date) VALUES (:product, :quantity, :terminal, NOW ())
-If a database record matches perfectly: product, quantity and terminal: Do nothing
-If a database record contains: same product but different quantity and / or terminal :
UPDATE table SET quantity=:quantity, terminal=:terminal