PHP Chinese processing Chinese character string truncation (mb_substr) and obtaining Chinese character string words. For more information, see. 1. Chinese interception: mb_substr ()
Mb_substr ($ str, $ start, $ length, $ encoding)
$ Str: string to be truncated
$ Start: truncates the start point. The start point is 0.
$ Length, number of words to be intercepted
$ Encoding: webpage encoding, such as UTF-8, GB2312, and GBK
Instance:
The result shows: PHP
2. get Chinese characters: mb_strlen ()
Mb_strlen ($ str, $ encoding)
$ Str: string to calculate the length
$ Encoding: webpage encoding, such as UTF-8, GB2312, and GBK
Instance:
Result: 24
For more articles about how to process Chinese character string truncation (mb_substr) in PHP and how to obtain the number of characters in a Chinese character string, refer to PHP Chinese website!