I have an HTML form that looks like this:
<form action="index.php" method="post">
<input type="hidden" value="Hidden Value" name="A Hidden Value" />
<select name="dropdownOption">
<option value="First Choice +200">First Choice</option>
<option value="Second Choice +300">Second Choice</option>
</select>
<p><input type="checkbox" value="Rocket +100"> Rocket</p>
</form>
I’m looping through the values of this form like this:
foreach($_POST as $key => $value) {
}
How would I exclude the hidden inputs from the foreach loop?
On a side note, does all versions of PHP support spaces in the input name (e.g. is valid?) In my version of PHP it automatically replaces spaces with underscores which is great, does it do that for all versions of PHP?
Thanks for any help.
There is no way to distinguish between different types of HTML input fields in php. My suggestion would to be to use some sort of prefix or other identifier in the names of your hidden fields. Then you can check to see if this prefix is present in the name of your fields in the loop. You could do