用< br>替换换行符 - PHP [英] Replacing a newline with a <br> - PHP

查看:137
本文介绍了用< 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 />

这篇关于用&lt; br&gt;替换换行符 - PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆