Richard Lynch wrote:
On Sat, June 18, 2005 10:11 am, Merlin said:
...

I believe that in recent versions of PHP, the preg_* functions will accept
an array as an argument... Or maybe I dreamed that.


FYI I thought this also... but it appears that you can only do one match at a time with preg_match(). The only one I found that allows the array syntax that you're referring to above is preg_replace().

All the same you can still set up an array full of regex patterns, loop through each of these, and do whatever you want with those matches.

<?php

$regs = array(
          '/match this text/',
          '/match this/',
          '/match/'
        );
$text = "Why don't you run this code and see if you can match this example?";

$matches = array();
foreach($regs as $regex) {
  preg_match($regex, $text, $matches[]);
}

print_r($matches);

?>

--
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to