What are some common pitfalls and irregularities associated with the str_word_count function in PHP, particularly when testing with different environments and Umlaut characters?

The str_word_count function in PHP may not accurately count words when dealing with Umlaut characters (such as ä, ö, ü) due to how it defines word boundaries. To ensure accurate word counting with Umlaut characters, it is recommended to use the mb_str_word_count function, which supports multibyte characters.

$text = "über ändern schön";
$wordCount = mb_str_word_count($text);
echo $wordCount; // Output: 3