以下代码在第二个elseif语句中返回语法错误:
if(($Rec["gradyear"] = $mydate[year] && $mydate[month] IN ("January","February","March","April","June","July")) || ($Rec["gradyear"] = $mydate[year] -1 && $mydate[month] IN ("August","September","October","November","December"))) {
$bgcolor="#00FF00";
} elseif(($Rec["gradyear"] = $mydate[year] -1 && $mydate[month] IN ("January","February","March","April","June","July")) || ($Rec["gradyear"] = $mydate[year] -2 && $mydate[month] IN ("August","September","October","November","December"))) {
$bgcolor="#FFFF00";
} elseif(($Rec["gradyear"] = $mydate[year] -2 && $mydate[month] IN ("January","February","March","April","June","July")) || ($Rec["gradyear"] = $mydate[year] -3 && $mydate[month] IN ("August","September","October","November","December"))) {
$bgcolor="#FF0000"; $fontcolor="#FFFFFF";
}
对于我的生活,我无法找到它。任何帮助将不胜感激。
另外,如果我没有提供足够的信息,我会提前道歉。这是我第一次在这里发帖,所以请保持温柔。 :)
答案 0 :(得分:1)
无效。
在php中使用 in_array 。
例如:
in_array($mydate[month] ,
array("January","February","March","April","June","July")
);
答案 1 :(得分:0)
将“IN”替换为in_array作为首发,将“$ mydate [month]”更改为“$ mydate ['month']”......乍一看...尝试简化你的if ...