[英]PHP check any key of array has null value
I have a array like我有一个像
$question = array(
'description'=>'some description',
'answer_one'=>'some answer',
'answer_two' => NULL)
I need to check any key of this array contains null value in quickest way.我需要以最快的方式检查该数组的任何键是否包含空值。
$key = array_search(null, $question);
Try this:尝试这个:
$question = array(
'description'=>'some description',
'answer_one'=>'some answer',
'answer_two' => NULL);
foreach ($question as $key => $value) {
if ($value == "") {
echo $key . " is empty!";
}
}
if (in_array(NULL, $question)) {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.