andz Posted July 14, 2009 Share Posted July 14, 2009 hi everyone. i have this file that i need to validate the content using preg_match. $pregMatch = array('html', 'body', 'script', '<script>', '</script>'); $text = 'this is my text'; how do i put this on preg_match()? Link to comment https://forums.phpfreaks.com/topic/165900-how-to-use-preg_match/ Share on other sites More sharing options...
trq Posted July 14, 2009 Share Posted July 14, 2009 Define validate. Link to comment https://forums.phpfreaks.com/topic/165900-how-to-use-preg_match/#findComment-875049 Share on other sites More sharing options...
andz Posted July 14, 2009 Author Share Posted July 14, 2009 i'd like to put it this way. preg_match(in_array($pregMatch), $text); but giving me an error. Link to comment https://forums.phpfreaks.com/topic/165900-how-to-use-preg_match/#findComment-875057 Share on other sites More sharing options...
trq Posted July 14, 2009 Share Posted July 14, 2009 You need to tell us what you mean by validate before we can even start showing you how to use preg_match Link to comment https://forums.phpfreaks.com/topic/165900-how-to-use-preg_match/#findComment-875061 Share on other sites More sharing options...
phporcaffeine Posted July 14, 2009 Share Posted July 14, 2009 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/165900-how-to-use-preg_match/#findComment-875158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.