This question already has an answer here:
So I'm trying to prepend a <br>
tag in front of the longest word encountered in a given string in PHP. The strings I'm working with may also contain characters from various languages, but all the strings are encoded in UTF-8.
// Here I'm prepending a <br> tag before the longest word in $words which is a subset of $string
substr_replace($string, "<br>", strpos($string , $words[$longest]) - 1, 0);
But I've noticed that when I modify a string of Korean or Russian text with this line of code, a U+FFFD character gets inserted, even replacing some characters in the string. Would anyone have a clue as to why that occurs?
Thanks
</div>