No , because how does your program know what should exist?
However, if you have a list of fields that are expected, you can easily write a function to check. I called it array_keys_exist because it does the same thing as array_key_exists , with the exception of a few keys:
function array_keys_exist($keys, $array) { foreach ($keys as $key) { if (!array_key_exists($key, $array)) return false; } return true; } $expectedFields = array('name', 'email'); $success = array_keys_exist($expectedFields, $_POST);
source share