W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
限制一行字符的長度(自動換行),默認是80個字符長度。 可選的第二個參數(shù),可自定義換行字符,默認換行字符是 "\n"
。 默認情況下,是根據(jù)單詞來換行的,也就是按英文語法的自動換行
。 如果你希望按照字符來換行(邊界的單詞將拆開),那么可以設(shè)置 可選的第三個參數(shù)為TRUE
,效果與PHP函數(shù)wordwrap()
一樣。
參數(shù)順序 | 類型 | 必選參數(shù) | 默認值 | 說明 |
---|---|---|---|---|
1 | integer | No | 80 | 限定一行的長度。 |
2 | string | No | \n | 換行符號 |
3 | boolean | No | FALSE | 設(shè)置按單詞換行(FALSE ),或者按字符換行(TRUE )。 |
Example 5.24. wordwrap
<?php $smarty->assign('articleTitle', "Blind woman gets new kidney from dad she hasn't seen in years." ); ?>
模板:
{$articleTitle} {$articleTitle|wordwrap:30} {$articleTitle|wordwrap:20} {$articleTitle|wordwrap:30:"<br />\n"} {$articleTitle|wordwrap:26:"\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 kidn ey from dad she hasn't se en in years.
參見 nl2br
和 {textformat}
.
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: