转换< br />进入文本区域使用的新行 [英] Converting <br /> into a new line for use in a text area
本文介绍了转换< br />进入文本区域使用的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个变量:
If I have a variable:
$var1 = "Line 1 info blah blah <br /> Line 2 info blah blah";
和一个文本区域:
And a text area:
<textarea>echo $var1</textarea>
如何让文本区域显示新行,而不是像显示文本一样在< br />
中?
How can I get the text area to display a new line instead of displaying the text on a single like with a <br />
in it?
编辑:尝试以下方法:
I have tried the following:
<textarea class="hobbieTalk" id="hobbieTalk" name="hobbieTalk" cols="35" rows="5" onchange="contentHandler('userInterests',this.id,this.value,0)"><?php
$convert=$_SESSION["hobbieTalk"];
$convert = str_replace("<br />", "\n", $convert);
echo $convert;
?></textarea>
但是文本区域仍然包含 br
However the text area still contains the br
tags in the lines.
推荐答案
Try this one
<?
$text = "Hello <br /> Hello again <br> Hello again again <br/> Goodbye <BR>";
$breaks = array("<br />","<br>","<br/>");
$text = str_ireplace($breaks, "\r\n", $text);
?>
<textarea><? echo $text; ?></textarea>
这篇关于转换< br />进入文本区域使用的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文