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 function

Example 5-18. strip

<?php

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

?>

where index.tpl is:

其中 index.tpl 內容為:

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

This will output:

輸出結果為:

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.