我有一个类似
的数组$question = array(
'description'=>'some description',
'answer_one'=>'some answer',
'answer_two' => NULL)
我需要以最快的方式检查此数组的任何键是否包含空值。
答案 0 :(得分:2)
$key = array_search(null, $question);
答案 1 :(得分:1)
试试这个:
$question = array(
'description'=>'some description',
'answer_one'=>'some answer',
'answer_two' => NULL);
foreach ($question as $key => $value) {
if ($value == "") {
echo $key . " is empty!";
}
}
答案 2 :(得分:0)
if (in_array(NULL, $question)) {
}