我正在尝试减少这个日期函数中的计数器变量(x):
date('Y-m-d', strtotime(x days'))
在这样的一段时间内循环:
$Today = date('Y-m-d', strtotime('-1 days'));
到目前为止的产量:2015-06-25
$x = -1;
while ($row = mysql_fetch_array($result1)) {
$Today = date('Y-m-d', strtotime('$x days'));
...
$x = $x - 1;
}
while循环下一次迭代的期望输出:2015-06-24等等。。。
除了必须使用双引号字符串对变量进行插值外,您已经拥有的内容将起作用,如strtotime("$x days")
–@Michael Berkowski