跳到内容

strip

此功能使用单个空格或提供的字符串替换所有空格、新行和制表符。

基本用法

{$myVar|strip}

注意

如果您想取消模板文本的块,请使用内置 {strip} 函数。

示例

<?php
$smarty->assign('articleTitle', "Grandmother of\neight makes\t    hole in one.");
$smarty->display('index.tpl');

模板为

{$articleTitle}
{$articleTitle|strip}
{$articleTitle|strip:'&nbsp;'}

将输出

Grandmother of
eight makes        hole in one.
Grandmother of eight makes hole in one.
Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one.

另请参见 {strip}truncate