Home  >  Article  >  Backend Development  >  Usage of php Chinese interception string mb_substr

Usage of php Chinese interception string mb_substr

WBOY
WBOYOriginal
2016-07-25 08:58:28902browse
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; 
?>

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



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn