Smarty Truncate intercept string
Intercepts a length of characters from the beginning of a string, with a default length of 80
Specifies the length of the second argument as the Intercept string
By default, Smarty is truncated to the end of a word,
If the exact number of characters to intercept can be used, use the third parameter to set it to "true"
The specific usage is as follows:
Copy CodeThe code is as follows:
index.php $smarty = new Smarty;
$smarty->assign (' ArticleTitle ', ' both 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:
Sisters reunite after eighteen years at Checkout Counter.
Sisters reunite after eighteen years at Checkout Counter.
Sisters reunite after ...
Sisters reunite after
Sisters Reunite After-
Sisters reunite after Eigh
Sisters reunite after E ...
http://www.bkjia.com/PHPjc/327740.html www.bkjia.com true http://www.bkjia.com/PHPjc/327740.html techarticle smarty truncate intercept a string from the beginning of the string to intercept a certain length of character, the default length of 80 specifies the second parameter as the length of the Intercept string by default, Smarty will intercept ...