What potential pitfalls should be considered when using str_word_count in PHP to count words in a string?

One potential pitfall when using str_word_count in PHP to count words in a string is that it may not accurately handle special characters or multibyte characters, resulting in incorrect word counts. To address this issue, you can use the mb_str_word_count function instead, which is specifically designed to handle multibyte characters and special characters.

$string = "Hello, world! 你好,世界!";
$wordCount = mb_str_word_count($string);
echo $wordCount; // Output: 5