-2

以下代码在第二个 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";
}

为了我的一生,我找不到它。任何帮助将不胜感激。

另外,如果我没有提供足够的信息,我提前道歉。这是我第一次在这里发帖,所以请温柔。:)

4

2 回答 2

1

无效。

在 php 中使用in_array 。

例如:

in_array($mydate[month] ,
array("January","February","March","April","June","July")
);
于 2013-08-13T21:09:22.877 回答
0

将“IN”替换为 in_array 对于初学者,将“$mydate[month]”更改为“$mydate['month']”...乍一看...尝试简化您的 if`s...

于 2013-08-13T21:06:08.590 回答