我如何遍历 $departments 数组并测试它是否等于 $name 变量值,如果它在列表中则返回“已检查”。部门是一组复选框
function isChecked($name) {
$departments = (isset($_POST["interests"])) ? $_POST["interests"] : array();
foreach ($departments as $key => $value) {
// this next line here is wrong
if($departments[$key][$value] == $name) {
return "checked";
};
}
return "";
}