How do you perform a preg_match where the pattern is an array, in php?

前端 未结 7 1384
予麋鹿
予麋鹿 2020-12-16 20:41

I have an array full of patterns that I need matched. Any way to do that, other than a for() loop? Im trying to do it in the least CPU intensive way, since I will be doing

相关标签:
7条回答
  • 2020-12-16 21:21

    What about doing a str_replace() on the HTML you get using your array and then checking if the original HTML is equal to the original? This would be very fast:

     $sites = array(
          'you_tube' => array('dead', 'moved'),
          ...
     );
     foreach ($sites as $site => $deadArray) {
         // get $html
         if ($html == str_replace($deadArray, '', $html)) { 
             // video is live
         }
     }
    
    0 讨论(0)
提交回复
热议问题