wordwrap

PHP Smarty

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

wordwrap 行宽约束

Parameter Position Type Required Default Description
1 integer No 80 This determines how many columns to wrap to.
指定段落(句子)的宽度
2 string No \n This is the string used to wrap words with.
使用什么字符约束
3 boolean No false This determines whether or not to wrap at a word boundary (false), or at the exact character (true).
是约束到词的边界(假)还是精确到字符(真)
index.php:

$smarty = new Smarty;
$smarty->assign('articleTitle', "Blind woman gets new kidney from dad she hasn't seen in years.");
$smarty->display('index.tpl');

index.tpl:

{$articleTitle}

{$articleTitle|wordwrap:30}

{$articleTitle|wordwrap:20}

{$articleTitle|wordwrap:30:"<br>\n"}

{$articleTitle|wordwrap:30:"\n":true}

OUTPUT:

Blind woman gets new kidney from dad she hasn't seen in years.

Blind woman gets new kidney
from dad she hasn't seen in
years.

Blind woman gets new
kidney from dad she
hasn't seen in
years.

Blind woman gets new kidney<br>
from dad she hasn't seen in years.

Blind woman gets new kidney fr
om dad she hasn't seen in year
s.

Prev 来源:PHP中文社区 Home Next
upper[大写] Up Combining Modifiers[组合使用调节器]