识别textarea中的每一行

时间:2013-07-19 21:02:38

标签: php

如果该行对于textarea来说很长并且有一个中断,我希望它在前面放一个大于号的符号。怎么样?正如你所看到的那样,遗漏了两个greater-than signs

> 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");

1 个答案:

答案 0 :(得分:0)

您可以使用wordwrap

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

只需确保$ cols与文本区域的col属性匹配即可。我减去2来计算要添加的'> “