smarty 截取字符串解决方法

WBOY
Release: 2016-06-13 11:08:22
Original
928 people have browsed it

smarty 截取字符串

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