duanchi0883649 2014-05-15 14:51
浏览 50
已采纳

我怎么能preg_grep一个日期

I try to grep a date. $m[0] is dpr_ts><'01/01/2002','31/12/2002'] .

I try to grep 01/01/2002 and 31/12/2002:

$se = preg_grep("/(\d{2}.\d{2}.\d{4})+/", $m);

I'm matching everything. I want to match the dates in an array $se[0] = '01/01/2002' and $se[1] = 31/12/2002.

  • 写回答

1条回答 默认 最新

  • dongpo5264 2014-05-15 14:58
    关注

    You want preg_match_all:

    preg_match_all("/(\d{2}.\d{2}.\d{4})+/", $m[0], $se);
    
    print_r($se);
    

    Also, using $m[0] makes me suspect that this was a match from a previous preg_match or preg_match_all? Maybe you could do it there and not have so many steps?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?