Home >Backend Development >PHP Tutorial >『PHP』PHP截断函数mb_substr()使用介绍_PHP

『PHP』PHP截断函数mb_substr()使用介绍_PHP

WBOY
WBOYOriginal
2016-06-01 12:08:09881browse

Function: mb_substr( $str, $start, $length, $encoding )

$str,需要截断的字符串
$start,截断开始处
$length,长度(注意,这个跟mb_strimwidth不同,1就代表一个中文字符)
$encoding,编码,我设为 utf-8

例:截断文章标题,控制在15个文字
复制代码 代码如下:

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