PHP: search substring within a string using preg_match?

PannaxWaf

New Member
Im trying to create a function to check for a substring within a string in php.\[code\]public static function stringCheck ($string, $substring) { $patern = "/".$substring."/"; if (preg_match($substring, string) { return true; } else return false;}\[/code\]but if i enter a special character used in preg_match (^.[$()|*+?{) it screws up the search.I tried something like the code below but that didnt work\[code\]$speicalChar = '/(\^|\.|\[|\$|\(|\)|\*|\+|\?|\{|\\)/';\[/code\]Anyone have a solution or maybe an alternative to preg_match. keep in mind that i want to be able to check for symbols too. I tried using strstr but had issues with symbols.Thanks =]
 
Back
Top