If you work with strings encoded as UTF-8, you may lose characters when you try to get some of them using the PHP substr function. This is because in UTF-8 characters are not limited to one byte, they have a variable length to match Unicode characters, between 1 and 4 bytes.
You can use mb_substr () . It works almost the same as substr, but the difference is that you can add a new parameter to indicate the type of encoding, whether UTF-8 or another encoding.
Try the following:
$str = mb_substr($article['CBody'], 0, 20, 'UTF-8'); echo utf8_decode($str);
Hope this helps.
source share