1. Chinese interception: mb_substr()
mb_substr( $str, $start, $length, $encoding )
$str, the string that needs to be truncated
$start, the starting point of truncation, the starting point is 0
$length, to Number of words intercepted
$encoding, web page encoding, such as utf-8, GB2312, GBK
Example:
Copy code The code is as follows:
$str='This site: http:/ /www.jb51.net';
echo mb_substr($str,0,4,'utf-8');//Intercept the first 5 characters, assuming that the encoding of the php file where this code is located is utf-8
?>
The results show: This website
Copy code The code is as follows:
$str='This site: http://www.jb51.net';
echo mb_strlen($str,' utf-8');//Assume that the encoding of the php file where this code is located is utf-8
?>
The result shows: 24
The above introduces submithandler PHP Chinese processing, Chinese string interception mb_substr and obtaining the number of Chinese string characters, including the content of submithandler. I hope it will be helpful to friends who are interested in PHP tutorials.