Assuming that you are tyring to create a validation function named as isvalid
;
function isvalid($input) {
return ('' !== trim($input));
}
// loop
$errors = arrray();
foreach ($_POST as $key => $value) {
if (!isvalid($value)) {
$errors[] = "$key not be empty!";
}
}
print_r($errors);
Meanwhile, if $_POST
input is not isset, then it won't be in foreach.