How can substr_count function be used to check if a string is part of another string in PHP?
To check if a string is part of another string in PHP, you can use the substr_count function. This function returns the number of times a substring appears in a given string. By checking if the result is greater than 0, you can determine if the substring is present in the string.
$string = "Hello, world!";
$substring = "world";
if (substr_count($string, $substring) > 0) {
echo "Substring found in string.";
} else {
echo "Substring not found in string.";
}