地区 :[ 切换城市 ]       新闻 娱乐 企业 博客 视频 工具 网站建设 开发者 旅行 社区

手机生活网

解析smarty 截取字符串函数 truncate的用法介绍

  • 2016-12-21 01:05:44 发布
  • 浏览:9226 次
  • 近一个月发布3条帖子
解析smarty 截取字符串函数 truncate的用法介绍
市微信朋友圈广告开户,广告制作,广告投放。
9级金牌商家

超过98%同行

会员2年 营业执照认证
服务支持
先行赔付
35个月
加入生活网
347个
发布帖子
2000元
保障金
  • 人气 3.0 ↑
  • 活跃 3.0 ↑
  • 服务 3.9 -

温馨提示:1、在办理服务前请确认对方资质, 夸大的宣传和承诺不要轻信!2.任何要求预付定金、汇款至个人银行账户等方式均存在风险,谨防上当受骗!

设施服务

更多参数
是否上门
上门服务

服务描述

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

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


联系我时,请说是在 看到的,谢谢!


店铺信息

筛选
深圳
全部区域
© 2018 Baidu - GS(2016)2089号 - 甲测资字1100930 - 京ICP证030173号 - Data © 创梦科技

猜你喜欢

    您好!没有信息,请您浏览其它内容。

您可能感兴趣


  • 您好!没有信息,请您浏览其它内容。
其他人还浏览
    您好!没有信息,请您浏览其它内容。