smarty 截取字符串
<br /><br />$str['name'] = "截取字符串长度"<br />$str['name'] = "取字符串长度"<br /><br /><{$$str.name|truncate_cn:"6":"..."}> 这样的话小于6位的也带... <br /><br />怎么判断$str['name'] 的字符是不是大于6啊才加...啊? <br /><br />
------解决方案-------------------- 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