Are there any potential issues with using substr_count() to count the frequency of a word in PHP?

One potential issue with using substr_count() to count the frequency of a word in PHP is that it is case-sensitive, meaning it will not differentiate between uppercase and lowercase versions of the word. To solve this issue, you can convert both the input string and the word to lowercase before using substr_count().

$input_string = "The quick brown fox jumps over the lazy dog";
$word = "the";

$input_string_lower = strtolower($input_string);
$word_lower = strtolower($word);

$word_frequency = substr_count($input_string_lower, $word_lower);

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