How to get a substring of Chinese or Japanese text without cutting off characters in PHP?

Posted by & filed under Website Development.

I used to try to get substrings of Chinese text and would get partial characters than came out as strange diamonds or squares…. until I found the mb_strcut() function! When using PHP, avoid using the substr() function, as it will often cut off Chinese and Japanese characters. For example: $text = ‘拿小锤锤的那个人好可爱的说,哈哈哈,生活太有爱了,加油加油了’; echo substr($text, 0,… Read more »