I'm checking 11 variables if they are empty and based on that adds a value to an array. The variables are not in an array and I'd like to keep them that way if possible.
if (!empty($var1)) {
$Data[] = $var1;
} else {
$Data[] = ' - ';
}
if (!empty($var2)) {
$Data[] = $var2;
} else {
$Data[] = ' - ';
}
if (!empty($var3)) {
$Data[] = $var3;
} else {
$Data[] = ' - ';
}
Is there a better/shorter way to do the above?
Aucun commentaire:
Enregistrer un commentaire