Jump to content

how to use PREG_MATCH()


andz

Recommended Posts

i'd like to put it this way.

 

preg_match(in_array($pregMatch), $text);

 

but giving me an error.

 

Firstly, in_array() requires at least two parameters. If your looking to find the existence of a string within a string or a 'subString' then try this:

 


<?php
$content = 'this is my text';

$patterns = array('html', 'body', 'script', '<script>', '</script>');

foreach ($patterns as $value) {

   if (strstr($content, $value)) {
   
      echo "Found";

}

else {
   
     echo "Not Found";

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.