I have two tables - I want to compare their values. If the $xml codes are in the $db, I create the product_db variable, if not - I will display the echo with the relevant information. Unfortunately - I get information undefined offset. I tried with $xml[0] as $product_xml, although it displays the malfunction of the function and only gets the first index of the array - while I need to compare all.
$xml = array(
array(
"code" => 456,
"stock" => 33,
"price" => 249.00,
),
array(
"code" => 789,
"stock" => 0,
"price" => 199.00,
),
);
$db = array(
array(
"code" => 456,
"stock" => 432,
"price" => 251.00,
),
array(
"code" => 789,
"stock" => 1,
"price" => 299.00,
),
);
foreach ($xml as $product_xml) {
if (in_array($product_xml['code'], array_column($db, 'code'))) {
$product_db = $db[$product_xml['code']];
$update = false;
} else {
echo 'error';
}
}