To check if a string contains another string in PHP, we could use the strpos() function which return the position of the first $needle found in $haystack.
- strpos($haystack, $needle)
The following example demonstrates the proper use of strpos().
<?php
$content = 'Eureka! - https://ykyuen.wordpress.com';
if (strpos($content, 'ykyuen') === false) {
// String not found
print "Missed.";
} else {
// String is found
print "Bingo!";
}
?>
Please refer to the link below for more information on checking if a string contains another string.
Done =)
Reference:

Thanks for the great post. I think that site really helped clear up the concept for me as well:
http://www.programmerinterview.com/index.php/php-questions/find-if-string-contains-another-string-php/
LikeLike
You are welcome and thanks for the link. =)
LikeLike