strip
去除(多余空格)

This replaces all repeated spaces, newlines and tabs with a single space, or with a supplied string.

替换所有重复的空格,换行和tab为单个.

Note: If you want to strip blocks of template text, use the strip function.

注意:如果想要去除模板的区块,请使用 strip函数

Example 5-19. strip
例 5-19.去除(多余空格)

index.php:



$smarty = new Smarty;

$smarty->assign('articleTitle', "Grandmother of\neight makes\t    hole in one.");

$smarty->display('index.tpl');



index.tpl:



{$articleTitle}

{$articleTitle|strip}

{$articleTitle|strip:" "}



OUTPUT:



Grandmother of

eight makes        hole in one.

Grandmother of eight makes hole in one.

Grandmother of eight makes hole in one.