我只想在一周中的某些日子显示一些html。我想我已经很接近了,但无法让它发挥作用。谢谢你的帮助。
<?php
$dayofweek = date('l');
$daystoshow = array('Thursday','Sunday','Wednesday');
if ($dayofweek == $daystoshow) {
echo "show this";
}
?>
使用in_array()
检查数组中是否有值:
if (in_array($dayofweek, $daystoshow)) {
Allright:
让我们使用PHP
日期函数
是否只在特定月份显示?
$date = date("m");
if ($date == "01") { // only on january
//output
}
你想只在某一天显示吗?
$date = date("d");
if ($date == "01") { //Only on the first of the month
//output
}
你想只在特定的日子放映吗?
$days = array("01","11","28");
$date = date("d");
if (in_array($date,$days)) { //Only 01,11,28
//output
}
您想只在一周中的特定日子显示它吗?
$days = array("Thursday","Sunday","Wednesday");;
$date = date("l");
if (in_array($date,$days)) {
//output
}
你想只在某一年展示吗?
$date = date("Y");
if ($date == "2014") { //Only on 2014
//output
}