商品对比

我的购物车

您好, 欢迎来到   Conmeng商城 [ 登录 ]  [ 注册 ]     [ 中国 ]   [ 切换语言 ]

扫描二维码

下载手机客户端
我的商城

最近浏览的商品

全部浏览历史
购物车结算

最新加入的商品

首页> 新闻资讯

最新新闻

国漫:看似是孩子观看的动画,实际上是给青少年以上人群观看的

2016-12-21 01:05:44

smarty truncate 截取字符串
从字符串开始处截取某长度的字符,默认的长度为80
指定第二个参数作为截取字符串的长度
默认情况下,smarty会截取到一个词的末尾,
如果需要精确到截取多少个字符可以使用第三个参数,将其设为”true”
具体用法如下:

复制代码代码如下:

//index.php $smarty = new Smarty; 
$smarty->assign('newsTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.'); 
$smarty->display('index.tpl'); 
//index.tpl 
{$newsTitle} 
{$newsTitle|truncate} 
{$newsTitle|truncate:30} 
{$newsTitle|truncate:30:""} 
{$newsTitle|truncate:30:"---"} 
{$newsTitle|truncate:30:"":true}
{$newsTitle|truncate:30:"...":true}

输出结果:
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after…
Two Sisters Reunite after
Two Sisters Reunite after—
Two Sisters Reunite after Eigh
Two Sisters Reunite after E…

请填写您的客服代码
如果您没有统计代码,推荐使用搜寻分析工具!