Smarty剪切字符串以添加点

Nei*_*eil 5 php smarty

我有这个代码:

{if $data|@count gt 0}

  {section name=field loop=$data}

    {$data[field].description|substr:0:120}...

    <hr/>

  {/section}

{/if}
Run Code Online (Sandbox Code Playgroud)

它表明abc123 abc123 a....

我怎么能得到不切的话?

mob*_*ius 13

为什么不使用截断修饰符http://www.smarty.net/docsv2/en/language.modifier.truncate

您可以将其设置为不打破单词.