我当前正在MySQL数据库中存储文本区域输入(HTML)。
使用php中的nl2br()
函数保留textarea中的新行。
要发布存储的值,我使用了以下代码:
$post = getSinglePost($topic,$postId)[0]; //This is a function that retrieves a single post from my SQL database
$precontent = $post['postContent'];
$anotherContent = str_ireplace("<br />","<br>",$precontent);
最后一行是我遇到的问题。由于某些原因,str_ireplace
对<br />
以外的任何其他字符串值起作用。
有人可以指出代码有什么问题吗?