Hi I have to search two strings in one string. For example
$string = "The quick brown fox jumped over a lazy cat";
if($string contains both brown and lazy){
then execute my code
}
I have tried pregmatch like this,
if(preg_match("/(brown|lazy)/i", $string)){
execute my code
}
But it enters if loop if one of them is present in the string. But i want it enter the if condition only if both of the strings are present in the parent string. How can I achieve this.
NoTE: I don't want loop over the string. (just like explode
the string and foreach
over the exploded array and search using strpos
)