$type_array = array(0 => "ctp", 1 => "flm"); $side_array = array(0 => "a", 1 => "b"); for ($p = 0; $p < count($type_array); $p++) { for ($q = 0; $q < count($side_array); $q++) { for ($i = 0; $i < $count; $i++) { if (substr_count($keys[$i], $type_array[$p] . "_prepressId_" . $side_array[$q] . "_") > 0) { $index = substr($keys[$i], -1, 1); $id = $_POST[$type_array[$p] . "_prepressId_" . $side_array[$q] . "_" . $index]; $rate_count = $_POST[$type_array[$p] . "_count_" . $side_array[$q] . "_" . $index]; $componentPrepress = new ComponentPrepress(); $componentPrepress->rate_id = $id; $componentPrepress->count = $rate_count; $componentPrepress->side = $side_array[$q]; $componentPrepress->type = $type_array[$p]; $componentPrepress->component_id = $component->id; $componentPrepress->save(); } } } } //// Status Update if (isset($_REQUEST['calculant_id']) && !empty($_REQUEST['calculant_id']) && !is_null($_REQUEST['calculant_id'])) { $component->status_update('', $component->id, '', $_REQUEST['calculant_id']); } elseif (isset($_REQUEST['stat_action']) && !empty($_REQUEST['stat_action']) && !is_null($_REQUEST['stat_action'])) { $component->status_update('', $component->id, $_REQUEST['stat_action'], ''); } else { $component->status_update('', $component->id, '', ''); } ///////////////// $record = $component->get_calc_record($component->id); if (!empty($record) && !is_null(!$record)) {