【发布时间】:2017-06-01 10:41:43
【问题描述】:
所以我有以下 for 循环:
$arr = [];
for($x = date('j', strtotime('this week')); $x <= date('j', strtotime('this week + 6 days')); $x++)
{
dd('test');
$arr[$x] = [
'y' => $x,
's' => 0,
'c' => 0,
'cl' => 0
];
}
dd('test2');
问题是循环从未被访问过...... dd() 返回 'test2' 但 for 循环未被访问并且它不返回任何错误。 我也有类似的:
for($x = 1; $x <= date('t', strtotime('today')); $x++)
{
$arr[$x] = [
'y' => $x . ' ' . date('M', strtotime('today')),
's' => 0,
'c' => 0,
'cl' => 0
];
}
而且这个工作完美。我要做的是根据本周的天数或在以下情况下根据本月的天数为 $arr 生成索引。我只是不明白为什么一个有效而另一个无效。 感谢大家的时间和帮助!
【问题讨论】:
-
我会 var_dump
date('j', strtotime('this week'))看看你得到了什么 val -
我很确定“本周”不是你想要的。你想达到什么目的?
-
我尝试根据本周的天数来实现一个带键的数组。 date('j', strtotime('this week')) 返回 29
-
嗨,Alphonse,您的问题解决了吗?如果是,请将其标记为已解决,以帮助保持 S.O 清洁和其他有相同问题的人。谢谢!
标签: php