We can use the PHP strpos() Function to do that.
The strpos() function finds the position of the first occurrence of a string inside another string.
Syntax:
strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) : int
In simple terms,
strpos(the string to loon into, the string to find, start point of search)
First two parameters are required and third one is optional.
Example to search a word:
<?php
$word = "Yogesh";
$searchInThisString = "This website is Yogesh Chauhan's Blog";
if(strpos($searchInThisString, $word) !== false){
echo "word found";
//add more logic if you want
} else{
echo "word NOT found";
//add more logic if you want
}
?>
functions string strpos