Smarty Truncate intercept string
Intercepts a length of characters from the beginning of a string, with a default length of 80
Specifies the second parameter as the length of the Intercept string
By default, Smarty is intercepted to the end of a word,
If you need to be precise to how many characters to intercept you can use the third argument to set it to "true"
The specific usage is as follows:
Copy Code code 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 Results:
Two sisters reunite after eighteen Years at Checkout Counter.
Two sisters reunite after eighteen Years at Checkout Counter.
Two sisters reunite ...
Two sisters reunite after
Two sisters reunite after-
Two sisters reunite after Eigh
Two sisters reunite after E ...