asehgal asehgal - 1 year ago 97
PHP Question

preg match extract digits from string after pattern

I have a string of the form


How can I extract just the
portion in PHP ? I need to detect the string_t first and then pull out the digits.

Answer Source

You want something like this:

preg_match('/string_t_(\d+)/', $string, $captures);

$captures[1] will contain <digits> (assuming <digits> is composed entirely of numbers - if it's not, use the more general (.+) in place of (\d+)).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download