The substr () function can be used to split text. However, if the text to be split contains Chinese characters, you may encounter problems. in this case, you can use the mb_substr () mb_strcut function, mb_substr () the usage of mb_strcut is similar to that of substr (), but an additional parameter must be added at the end of mb_substr () mb_strcut to set the encoding of the string. However, php_mbstring.dll is not enabled on the general server. ini puts php... the substr () function can be used to split text. However, if the text to be split contains Chinese characters, you can use the mb_substr ()/mb_strcut function () the usage of/mb_strcut is similar to that of substr (), but an additional parameter must be added at the end of mb_substr ()/mb_strcut to set the character string encoding. However, php_mbstring.dll is not enabled on the server, in php. ini is calling php_m Open bstring. dll. For example: Output: in this way, my words
1. php intercepts the mb_substr () and mb_strcut () functions of the Chinese string length.
Brief introduction: to solve the problem of intercepting Chinese strings in PHP, it is easy to intercept strings in English, just use substr directly, and there will be no garbled characters. chinese is a little troublesome. the following two solutions are provided: (1) directly use the mb_substr (); function of the Multi-Byte function library. the instance code is as follows:
7. PHP character string flip (including Chinese characters) php random generation string php get string length php character string ratio
Brief introduction: string, php: PHP string flip (including Chinese characters ):
8. submithandler PHP Chinese processing Chinese string capturing mb_substr and obtaining Chinese string words
Introduction: submithandler PHP Chinese processing Chinese string truncation mb_substr and obtaining Chinese string words: 1. Chinese interception: mb_substr () mb_substr ($ str, $ start, $ length, $ encoding) $ str: The String $ start to be truncated. the start value is 0 $ length. the number of words to be truncated $ encoding. the webpage encoding, such as UTF-8, GB2312, and GBK instances: the code is as follows:
9. PHP truncation function mb_substr ()
Introduction: PHP truncation function mb_substr ()
10. example of php truncation string function mb_substr ()
Brief introduction: php truncation string function mb_substr () example
[Related Q & A recommendations ]:
Substr-PHP-Chinese/English mixed-rank string truncation function
The above is the detailed content recommended by the 10 articles about mb_substr (). For more information, see other related articles in the first PHP community!