lfernando Posted May 9, 2011 Share Posted May 9, 2011 Hello, I have a few strings that contain dates along with some other text. The string looks like this: Hi, could you please add these dates to the database?<br /> <br /> <br /> 2-September-2011<br /> 6-September-2011<br /> 7-September-2011<br /> 8-September-2011<br /> 9-September-2011<br /> <br /> Thank you. Dates are always the same format. Sometimes there's a single date, most times there are multiple. Does anyone know how can I get the dates from this string to add them to my sql database? Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/235934-find-multiple-dates-in-a-string/ Share on other sites More sharing options...
AbraCadaver Posted May 9, 2011 Share Posted May 9, 2011 Something like: preg_match_all('/\d{1,2}-[^-]+-\d{4}/', $string, $matches); print_r($matches[0]); Quote Link to comment https://forums.phpfreaks.com/topic/235934-find-multiple-dates-in-a-string/#findComment-1212885 Share on other sites More sharing options...
lfernando Posted May 9, 2011 Author Share Posted May 9, 2011 horray! that works perfectly!! thank you so much Quote Link to comment https://forums.phpfreaks.com/topic/235934-find-multiple-dates-in-a-string/#findComment-1212889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.