您的位置 首页 php

thinkphp实现字符串截取

在公共的common.php中

加入下面方法

// 字符串 截取并且超出显示省略号

function subtext($text, $length)

{

if(mb_strlen($text, ‘utf8’) > $length)

return mb_substr($text,0,$length,’utf8′).’ …’;

return $text;

}

//在模版中调用则:

{$tops.title | subtext=18}

文章来源:智云一二三科技

文章标题:thinkphp实现字符串截取

文章地址:https://www.zhihuclub.com/150624.shtml

关于作者: 智云科技

热门文章

网站地图