逻辑 - 检查至少一个字段是否为空

时间:2012-04-02 15:18:14

标签: php forms file

我有这个代码,需要逻辑结束的帮助。我希望至少有一个字段不为空。

if(!empty($fileTypes) || !empty($fileSizes) || !empty($fileUploads) || !empty($features) || !empty($design) || !empty($other) || !empty($contact)) {
} else {
    $error = 1;
}

1 个答案:

答案 0 :(得分:1)

是道歉以下作品:

$array = array();

if($_POST){

        foreach ($_POST as $key => $value){
            if (!empty($value)){
                $array[$key] = $value;
            }
        }
        if (empty($array))
        {
        echo 'array empty';//throw error
        } else {
            echo 'array not empty'; //there is a submission
        }
}

编辑:错过了粘贴中的结束标记....已修复

相关问题