板邓:PHP使用mb_strimwidth截取中文字符串方法大全

按字符宽度获取

mb_strimwidth ( string $str , int $start , int $width [, string $trimmarker [, string $encoding ]] )

参数说明:

$str //指定字符串

$start //指定从何处开始截取

$width //截取文字的宽度

$trimmarker //超过$width数字后显示的字符串

$encoding //设置字符编码【例如:UTF-8】

举个例子来说明

<?php

$string="242432反对感是456犯得上广泛大使馆地方7890";
echo mb_strimwidth($string,0,14,'...','UTF-8');
?>

输出的结果就是:242432反对...

posted @ 2017-04-01 10:24  贵隆  阅读(198)  评论(0编辑  收藏  举报