<?
$test[] = 'one';
$test[] = 'two';
$test[] = 'three';
print implode(", ", $test);
?>
echoes out the string "one, two, three" (without quotes). This would solve the problem, provided that you have the values in an array. (I.e. use input names like answ[fieldname], then implode $answ)
Secondly, if you take each variable and add a comma between them, like this;
$fields = "f1 f2 f3 f4 f5"; // junk fieldnames
$outputString = '';
foreach (explode(' ', $fields) AS $key => $val) {
$outputString .= "$$val, ";
}
You can trim it to remove trailing space;
$outputString = trim($outputString);
And then remove the last character;
$outputString = substr($outputString, 0, strlen($outputString)-1);
.. Alternately use a regexp, a bit safer maybe;
ereg("(.*),$", $outputString, $new);
(then use $new[1])..