Im trying to create a function to check for a substring within a string in php.
public static function stringCheck ($string, $substring) {
$patern = "/".$substring."/";
if (preg_match($substring, string) {
return true;
}
else return false;
}
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
$speicalChar = '/(\^|\.|\[|\$|\(|\)|\*|\+|\?|\{|\\)/';
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 =]