// Json encoding! $test_params_total = $post['test_params_total']; $test_params = '{'; for($i=0; $i<$test_params_total; $i++) { $test_params .= '"'.$post['test_year'.$i].'"' . ':' . '"'.$post['test_passed'.$i].'", '; } $test_params = substr($test_params, 0, strlen($test_params)-2) . '}';