Using foreach() method, you can't eliminate the hidden fields:
reset($_POST);
foreach ($_POST as $key => $val) {
echo "$key : $val \n"; //$key is the variable name, $val is the answer from the form.
}
However, if you name your hidden fields in a particular way, like start all hidden field names with an underscore (), eg: fieldName1
Then you can modify the foreach() method to exclude such varaibles:
reset($_POST);
foreach ($_POST as $key => $val) {
if (!preg_match("/^_/", $key)) {
echo "$key : $val \n"; //$key is the variable name, $val is the answer from the form.
}
}