Firt solution, add values in array and tests if there is empty value
function checkEmptyValueArray($values) {
return !empty(array_filter($values, function ($value) {
return empty($value);
}));
}
$values = [$varone, $vartwo, $vthree, $vardf, $vfgsdgsdal, $pasadfsd, $efda];
if ( checkEmptyValueArray($values) ) {
$response = "There is an empty data";
} else{
$response = "NO EMPTY DATA!";
}
An other solution is to use variable-length arguments list
Follow this link for an explanation : https://www.php.net/manual/en/functions.arguments.php
function checkEmptyValueArray(...$args) {
foreach ( $args as $arg ) {
if ( empty($arg) ) {
return true;
}
}
return false;
}
if ( checkEmptyValueArray($varone, $vartwo, $vthree, $vardf, $vfgsdgsdal, $pasadfsd, $efda) ) {
$response = "There is an empty data";
} else{
$response = "NO EMPTY DATA!";
}