This article introduces an example of using the mb_substr function to intercept Chinese strings in PHP for your reference.
Use function mb_substr, example: <?php /** * mb_substr截取中文字符串 * edit bbs.it-home.org */ header('Content-Type:text/html;charset:utf-8'); $a = "脚本sdf学堂,欢迎sf3s大家的xfs光临。好幸fxesd福啊。"; $b = mb_substr($a, 0,10,'utf-8'); echo $b; ?> Copy after login For examples of the mb_substr function in php, you can also refer to: php truncate string function mb_substr() example Two functions for php to intercept Chinese strings (iconv_substr and mb_substr) php Chinese string interception (mb_substr) example |