php截断字符串函数mb_substr()范例
介绍下php函数mb_substr。
函数 mb_substr( $str, $start, $length, $encoding )
参数说明:
$str,需要截断的字符串
$start,截断开始处
$length,长度(注意,这个跟mb_strimwidth不同,1就代表一个中文字符)
$encoding,编码,我设为 utf-8
例子,截断文章标题,控制在15个文字:
echo mb_substr(get_the_title(), 0, 15,"utf-8");
//by www.jbxue.com
?>
您可能感兴趣的文章:
php中文截取字符串mb_substr的用法
php截断字符串函数mb_substr()范例
php中文字符截取函数(自用)
php截取中文字符串的二个函数(iconv_substr和mb_substr)
php中文字符串截取(mb_substr)实例
php如何截取字符串后四位
php中文字符串截取方法
php中文截取字符串函数(很好用)
php函数substr(),mb_substr()及mb_strcut的区别分析
php截取中文字符串(无乱码)方法