replace
替换

Parameter Position参数位置 Type参数类型 Required必需 Default默认 Description
1 string Yes n/a This is the string of text to be replaced.
将被替换的文本字串
2 string Yes n/a This is the string of text to replace with.
用来替换的文本字串

A simple search and replace on a variable.
简单的搜索和替换字符串

Example 5-16. replace
例 5-16.替换

index.php:

$smarty = new Smarty;
$smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
$smarty->display('index.tpl');

index.tpl:

{$articleTitle}
{$articleTitle|replace:"Garden":"Vineyard"}
{$articleTitle|replace:" ":" "}

OUTPUT:

Child's Stool Great for Use in Garden.
Child's Stool Great for Use in Vineyard.
Child's Stool Great for Use in Garden.

The CHM file was converted to HTM by Trial version of ChmDecompiler.
Download ChmDecompiler at: http://www.zipghost.com