$_POST
is populated as an associative array, so you can just do this:
foreach ($_POST as $name => $val)
{
echo htmlspecialchars($name . ': ' . $val) . "\n";
}
Additionally, if you're just interested in the field names, you can use array_keys($_POST);
to return an array of all the keys used in $_POST
. You can use those keys to reference values in $_POST
.
foreach (array_keys($_POST) as $field)
{
echo $_POST[$field];
}
- foreach documentation
- array_keys documentation