tags:

views:

20

answers:

1

Hello,

What's a quick way for matching the following in a multiline string using preg_match?

id=334534534

id= is constant, the digits are what I need to extract.

+2  A: 

The regexp'll be something like this: /id=(\d+)/im

Where the / are the reg exp delimitators, the i means "case insensitive" and m means "multi-line".

With preg_match_all() you can do this:

$subject = "YOUR STRING HERE";
$pattern = '/id=(\d+)/im';

preg_match_all($pattern, $subject, $matches);
print_r($matches);
TiuTalk