-1

我有一个日期数组,我想知道是否可以搜索一个数组并删除今天日期之前的任何项目,并保留其余的?

这是我的数组

Array
(
    [0] => Array
        (
            [date] => 2013-07-14
        )

    [1] => Array
        (
            [date] => 2013-08-31
        )

    [2] => Array
        (
            [date] => 2013-09-15
        )

    [3] => Array
        (
            [date] => 2013-10-12
        )

    [4] => Array
        (
            [date] => 2013-10-16
        )

    [5] => Array
        (
            [date] => 2013-10-19
        )

    [6] => Array
        (
            [date] => 2013-10-23
        )

    [7] => Array
        (
            [date] => 2013-10-26
        )

    [8] => Array
        (
            [date] => 2013-10-30
        )

    [9] => Array
        (
            [date] => 2013-09-07
        )

    [10] => Array
        (
            [date] => 2013-08-14
        )

    [11] => Array
        (
            [date] => 2013-08-24
        )

    [12] => Array
        (
            [date] => 2013-09-11
        )

    [13] => Array
        (
            [date] => 2013-09-28
        )

    [14] => Array
        (
            [date] => 2013-10-05
        )

)
4

3 回答 3

2

像这样的东西:

$buffer = array();
foreach ($dates as $element) {
    if (strtotime($element['date']) >= time()) {
        $buffer[] = $element;
    }
}
于 2013-05-16T06:38:12.460 回答
1

循环遍历并将日期与实际所需数据进行比较并构建一个新的过滤数组怎么样?

$newarray = array();
foraeach($array as $data)
{
     if($data['date'] >= $yourdate)
     {
         $newarray] = $data;
     }
}
于 2013-05-16T06:40:41.250 回答
0

array_walk函数允许您定义一个回调以在数组中的每个项目上运行。

于 2013-05-16T06:38:26.913 回答