检查所有数组项是否为空 PHP
2022-08-30 07:52:53
我正在从窗体中添加一个项数组,如果所有项都是空的,则我想执行一些验证并添加到错误字符串中。所以我有:
$array = array(
'RequestID' => $_POST["RequestID"],
'ClientName' => $_POST["ClientName"],
'Username' => $_POST["Username"],
'RequestAssignee' => $_POST["RequestAssignee"],
'Status' => $_POST["Status"],
'Priority' => $_POST["Priority"]
);
然后,如果所有数组元素都是空的,则执行:
$error_str .= '<li>Please enter a value into at least one of the fields regarding the request you are searching for.</li>';