<?php
$exclusions = [
'Discontinue Status' => [
'Discontinued',
'Run Down Stock',
],
'Hazardous' => [
'No',
],
];
$products = [
[
'Product ID' => '452',
'Discontinue Status' => 'Discontinued',
'Hazardous' => 'No',
],
[
'Product ID' => '463',
'Discontinue Status' => 'Normal',
'Hazardous' => 'No',
],
[
'Product ID' => '477',
'Discontinue Status' => 'Run Down Stock',
'Hazardous' => 'Yes',
],
[
'Product ID' => '502',
'Discontinue Status' => 'Discontinued',
'Hazardous' => 'No',
],
[
'Product ID' => '520',
'Discontinue Status' => 'Normal',
'Hazardous' => 'Yes',
],
];
foreach ($products as $index => $product) {
foreach (array_intersect_key($product, $exclusions) as $key => $value) {
if (in_array($value, $exclusions[$key])) {
unset($products[$index]);
break;
}
}
}
var_export(array_values($products));
preferences:
55.07 ms | 402 KiB | 5 Q