Niklas Riecken Niklas Riecken - 1 year ago 172
PHP Question

Preg Match Extracting

I want to extract a string out of a string.

I have the following String:


I would like to extract the
, which could be any int value

I already tried this pattern: ~(date-)*(-days)~
But its only giving me "date-" and "-days" back, but I want to receive the number.

How can I do this?


Answer Source
$returnValue = preg_match('/-(\d+)-/', '[date-454-days]', $matches);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download