如何简化preg_match调用?

preg_match("/foo1(.*)bar1/", $subject, $matches1);
preg_match("/foo2(.*)bar2/", $subject, $matches2);
preg_match("/foo3(.*)bar3/", $subject, $matches3);

I'm wondering how I can combine the three patterns, call preg_match only once and put all the matches into one array? As you probably know, preg_match doesn't accept an array as first parameter.

/foo([123])(.*)bar\1/ should do it, using preg_match_all, of course. $matches[2] will be the array you want.