仅当日期在某个点之后时,Foreach循环


Foreach loop only if date is after some point

只有在日期超过2013-09时,我才想结束循环,所以不想

2013-08
2013-09

但是

2013-10
2013-11
2013-11
2014-01

我的循环:

foreach ($data as $key=>$row) {
    $date = explode('-', explode(' ', trim(explode(' ', getTime($row))[0]))[0]);
    $year = intval($date[0], 10);
    $month = intval($date[1], 10);
    if (!($year >= 2013) || !($year == 2013 && $month >= 10)) {
        continue;
    }
    echo "{$year}-{$month}'n";
}

它给了我2013-10-01到2013-12-31的日期,但没有超过那个日期,为什么?

数组中的输入数据如下(如果很难从代码中读取,这里有vardump):

array (size=3)
  0 => string '2012' (length=4)
  1 => string '12' (length=2)
  2 => string '14' (length=2)
array (size=3)
  0 => string '2012' (length=4)
  1 => string '12' (length=2)
  2 => string '15' (length=2)

开始工作:

if (!($year >= 2013)) {
    continue;
}
if ($year == 2013) {
    if (!($month >= 10)) {
        continue;
    }
}