I have a simple form that inserts data into a database using foreach($_POST as $key=>$value) I have a hidden field on the form
<input name="isset" type="hidden" value="true" />
And i use if(isset($_POST[‘isset’])) {
I’m trying to work out how to exclude the hidden field from the loop …?
I’ve looked at this post but don’t understand where i would use if (strpos($key, ‘hdn_’) == false) // proceed
How to exclude <input type="hidden"> from a for each loop in PHP
any guidance would be appreciated….
If you know the exact names of keys you want to exclude,
array_diff_keyis a convenient option:However, since
$valuesis intended to go into the database you should use a whitelist of allowed keys instead of a blacklist. You can do that witharray_intersect_key: