I’m trying to match all the dates that are found in a string, here is the function
$description = "1999 2008 1998";
if(preg_match("/[12][0-9]{3}/", $description, $matches)){
print_r($matches);
}
The problem is that only the first date is returned which is 1999, I actually want to match all dates.
What should I change in the regex?
Do you mean this?
only difference is
preg_match_allinstead ofpreg_match.