2013-07-19 53 views
0

如果該行對於textarea來說很長並且有一箇中斷,我希望它在它前面放置一個大於號的符號。怎麼樣?正如你可以看到那裏有缺席兩場greater-than signs識別textarea中的每一行

> Vivamus ullamcorper adipiscing bibendum. 
> 
> Etiam faucibus facilisis tortor, 
> in viverra nulla condimentum eu. 
> Vivamus eu tellus adipiscing, molestie nisi vel, 
malesuada lacus. (wheres the greater-than sign?) 
> 
> Integer cursus malesuada 
consectetur. (wheres the greater-than sign?) 
> Curabitur tellus mi, tristique vel urna et, auctor tincidunt augue. 
> Cras semper, nisl sodales viverra volutpat. 
> Phasellus feugiat quam nec orci 
> accumsan gravida ut vitae risus. 

我已經試過這樣:rtrim("> ".str_replace("\n", "\n> ", $str), ">\n");

回答

0

您可以使用wordwrap這一點。

rtrim("> ".str_replace("\n", "\n> ", wordwrap($str, $cols -2 , "\n", true)), ">\n"); 

只要確保$ cols匹配您的文本區域的col屬性。我減去2以考慮添加'>'