What are some best practices for efficiently counting the occurrences of a word in a string using PHP?

When counting the occurrences of a word in a string using PHP, one efficient approach is to use the `substr_count()` function. This function counts the number of times a substring appears in a string without overlapping. By utilizing this function, you can easily and efficiently determine the frequency of a specific word within a given string.

$string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
$word = "ipsum";

$occurrences = substr_count($string, $word);

echo "The word '$word' appears $occurrences times in the string.";