Home  >  Article  >  Backend Development  >  smarty 截取字符串解决思路

smarty 截取字符串解决思路

WBOY
WBOYOriginal
2016-06-13 13:08:10746browse

smarty 截取字符串

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->

$str['name'] = "截取字符串长度"
$str['name'] = "取字符串长度"

  这样的话小于6位的也带...   

怎么判断$str['name'] 的字符是不是大于6啊才加...啊? 




------解决方案--------------------
if (count($t_string[0]) > $length) //如果超过指定长度
return join('', array_slice($t_string[0], 0, $length)) . $etc; //截取并加上 ...
return join('', array_slice($t_string[0], 0, $length)) . $etc; //那这句就不对了
应该是
return $string; // 原样返回
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn