I have list of words that needs to check is exact available or in string. Also words may be case sensitive.
For e.g. 1
Hello
world
how
are
I tried,
$url = "Hello world how are you ?";
$haystack = "Hello|world|how|are";
$check = (preg_match("({$haystack})", $url) === 1);
var_dump($check);
Output
true
This example checks like or
operator.
For e.g. 2
$url = "Hello world how are you ?";
$check = (strpos($url, "Hello") >= 0 && strpos($url, "world") && strpos($url, "how") && strpos($url, "are"));
var_dump($check);
Output
true
This example working but not check exact match try to change first Hello
word to hellosssss
it shows always true.
So, any preferable way to check all words exactly and also with case sensitive.
Note : This example shows only few words but I have many words.