smarty 截取字符串解决思路

WBOY
Release: 2016-06-13 13:08:10
Original
769 people have browsed it

smarty 截取字符串

PHP code
<!--

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

-->

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

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

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


Copy after login


------解决方案--------------------
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; // 原样返回
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template