Something like this?
foreach ($cost_array as $key1 => $value1) {
// group 1, group 2 and group 3 are empty and should stay => continue the foreach loop
if (empty($value1['group1']) && empty($value1['group2']) && empty($value1['group3']))
continue;
// if form group 1 exists and its value is the same as $value group 1, it should stay => continue the foreach loop
if (isset($form_group1) && $value1['group1'] == $form_group1)
continue;
// if form group 2 exists and its value is the same as $value group 2, it should stay => continue the foreach loop
if (isset($form_group2) && $value1['group2'] == $form_group2)
continue;
// if form group 3 exists and its value is the same as $value group 3, it should stay => continue the foreach loop
if (isset($form_group3) && $value1['group3'] == $form_group3)
continue;
// otherwise unset the value
unset($cost_array[$key1]);
}
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.