PHP: string match with array of regular expressions

I am writing a fast PHP parser here and wondered instead of writing

foreach($array as $line) {
  if(preg_match($regex1, ..) {

  } 
  elseif(preg_match($regex2, ..) {

  }
}

Is it possible to match an array of regular expression arrays?

+3
source share
1 answer
foreach($text_array as $line){
    foreach($regex_array as $regex{
        ...
    }
}
+1
source

Source: https://habr.com/ru/post/1765526/


All Articles