Problem with str_ireplace for a <br /> tag

45 Views Asked by At

I am currently storing a textarea input (HTML) in MySQL database.

The new lines in the textarea are preserved using nl2br() function in php.

To post the stored value, I've used the following code:

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

The last line is the one that I am having problem with. For some reason str_ireplace works on any other string value than <br />.

Could someone point what's wrong with the code?

0

There are 0 best solutions below