Question

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.

Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top