I have the following PHP code:
$required_fields = array ('menu_name','visible','position');
foreach($required_fields as $fieldname)
{
if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname]) )
{
$errors [] = $fieldname;
}
}
menu_name, visible and position are variables that are received through the post method.
When the value of visible is zero, it creates an entry into the error array.
What is the best way to detect if a variable is empty when 0 is considered "not empty"?