用< br>替换换行符 - PHP
问题描述:
我猜这是你可以在PHP中做的事情。我想要的是在按下提交按钮时将文本内容放入文本框中,并将所有换行转换为
I'm guessing this is something you can do in PHP. What I want is to get the text in a textfield when the submit button is pressed and convert all the newlines into
<br>'s.
请帮忙吗?
Help, please?
答
nl2br
会做你想做的事,我想。
nl2br
would do what you want, I think.
<?php
$str = "\n\nfoo\nbar";
echo nl2br($str);
输出:
<br />
<br />
foo<br />