$input = array("a" => "green", "red", "b" => "green", "blue", "red"); $result = array_unique($input); foreach ($result as $temp){ $return_text .= $temp; } array_push($result, "a", "b"); $update_data = array(); for ($i=0;$i<=count($session_update_db_field)-1;$i++) { $update_data[$session_update_db_field[$i]] = $this->input->post($session_update_form_field[$i]); }