explicitly test for the required key and assign it to the output array.
$rebate_by_product = array();
foreach ($_POST as $key => $val) {
if (!is_array($val)) {
$rebate_by_product[$key] = $val;
} elseif ($key == 'applicable_states') {
$rebate_by_product[$key] = $val;
} elseif (preg_match('/^product_id_(\d+)$/', $key, $match)) {
$i = $match[1];
if (isset($rebate_by_product[$i])) {
$rebate_by_product[$i][$key] = $val;
} else {
$rebate_by_product[$i] = array($key => $val);
}
} else {
foreach ($val as $i => $subval) {
if (isset($rebate_by_product[$i])) {
$rebate_by_product[$i][$key] = $subval;
} else {
$rebate_by_product[$i] = array($key => $subval);
}
}
}
}