The strpos function works fine, but if you want to do case-insensitive
checking for a word in a paragraph then you can make use of the stripos
function of PHP
.
For example,
$result = stripos("I love PHP, I love PHP too!", "php");
if ($result === false) {
// Word does not exist
}
else {
// Word exists
}
Find the position of the first occurrence of a case-insensitive substring in a string.
If the word doesn't exist in the string then it will return false else it will return the position of the word.