I have the below script which is working. I am looking for the string '1/72' I would also like to look for the string '1:72' and '1\72' - how would I go about doing this easily (apart from just using multiple if statements?)
$string="test string 1/72 PHP";
if (strpos($string, '1/72') > 0) {
print "Got match!
";
} else {
print "no match
";
}
Use preg_match
function.
if (preg_match("~1[\\\\:/]72~", $str)) {
[\\\\:/]
character class which matches a backslash or :
or forward slash.
The fnmatch() function also provides a simple way to use pattern matching with shell wildcard expressions
$string="test string 1/72 PHP";
if (fnmatch('*1[/:\\\\]72*', $string)) {
print "Got match!
";
} else {
print "no match
";
}