wordwrap
指定したカラム幅で文字列をワードラップします(デフォルトは80)。
第2パラメータには、次の行にワードラップするために使用される文字列を
指定する事が出来ます(デフォルトは\n)。デフォルトでは単語の境界でワードラップを行います。
厳密な文字数でワードラップしたい場合は第3パラメータにtrueを渡します。
例 5-22. wordwrap
<?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} |
出力 :
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<br />
years.
Blind woman gets new kidney
from dad she hasn't seen in
years. |
|