Usage of the string function truncate parsed by smarty
Source: Internet
Author: User
This article provides a detailed analysis of the usage of the string truncate function in smarty. For more information, see
Smarty truncate string Truncates a certain length of characters starting from a string. the default length is 80.
Specify the second parameter as the length of the truncated string
By default, smarty captures the end of a word,
If you need to specify the number of characters to intercept, you can use the third parameter and set it to "true"
The usage is as follows: The code is as follows:
// Index. php $ smarty = new Smarty;
$ Smarty-> assign ('articletitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter .');
$ Smarty-> display ('index. tpl ');
// Index. tpl
{$ ArticleTitle}
{$ ArticleTitle | truncate}
{$ ArticleTitle | truncate: 30}
{$ ArticleTitle | truncate: 30 :""}
{$ ArticleTitle | truncate: 30 :"---"}
{$ ArticleTitle | truncate: 30: "": true}
{$ ArticleTitle | truncate: 30: "...": true}
Output result: 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...
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.