nl2br

PHP Smarty

Smarty - the compiling PHP template engine
Prev 来源:PHP中文社区 Chapter 5. Variable Modifiers[变量调节器] Next

nl2br
换行符替换成
<br />


All linebreaks will be converted to <br /> tags in the given variable. This is equivalent to the PHP nl2br() function.
index.php:

$smarty = new Smarty;
$smarty->assign('articleTitle', "Sun or rain expected\ntoday, dark tonight");
$smarty->display('index.tpl');

index.tpl:

{$articleTitle|nl2br}

OUTPUT:

Sun or rain expected<br />today, dark tonight

Prev 来源:PHP中文社区 Home Next
lower[小写] Up regex_replace[正则替换]