Parse the usage of the string function truncate in smarty. Smartytruncate intercepts a string from the start of the string. the default length is 80. specify the second parameter as the string length. by default, smarty intercepts
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...
Http://www.bkjia.com/PHPjc/327740.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327740.htmlTechArticlesmarty truncate a string that captures a certain length from the start of the string. the default length is 80. specify the second parameter as the length of the truncated string. by default, smarty will intercept...