10 articles about mb_substr ()-php Tutorial

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.