Reputation:
Is there a shortcut to check if none of the values in the array are empty. I don't want to have to list it out one by one.
$form_inputs = array (
'name' => $name,
'gender' => $gender,
'location' => $location,
'city' => $city,
'description' => $description);
if (!empty(XXXXXXXX)){
echo 'none are empty';
} else {
header('Location:add.school.php?error=1');
exit();
}
Upvotes: 1
Views: 130
Reputation:
if (has_empty($form_inputs)) {
// header location
}
function has_empty($array) {
foreach ($array as $key=>$value) {
if (empty($value)) {
return true;
}
}
}
Upvotes: 2