【发布时间】:2017-08-06 06:39:34
【问题描述】:
for($whichPages = 0, $whichPages < $arrlength, $whichPages++) {if(($includeHome=='YES') && $today > $alertbegin && $today < $alertend) echo '<div class="msg" style="margin-bottom:25px">'.$alert.'</div>'};
上面的代码有一些语法问题。基本上我想说如果在数组 $whichPages 中,如果其他条件为真,则回显 html。不确定如何组合 for 循环和 if 子句。帮助不大。谢谢。
我有这段代码可以工作,但我希望对其进行简化
if(($includeHome=='YES' || $thisPage=='Class' || $thisPage=='Events' || $thisPage=='Gallery') && $today > $alertbegin && $today < $alertend)echo '<div class="msg" style="margin-bottom:25px">'.$alert.'</div>';
$thisPage 变量是我放入数组 $whichPages = array('Class','Events','Gallery')
【问题讨论】:
标签: php if-statement for-loop