I'm using php and mysql, I need to replace the line breaks that I put in my textarea by \ n to save it in my database, I wanted to know how I can do this. Thanks!
I'm using php and mysql, I need to replace the line breaks that I put in my textarea by \ n to save it in my database, I wanted to know how I can do this. Thanks!
I recommend you use the nl2br
function.
This function replaces \ n with <br>
.
Here I leave you a url: link
The inverse function does not exist, but you can create a function with regex , as follows:
<?php
function br2nl($string)
{
return preg_replace('/\<br(\s*)?\/?\>/i', "\n", $string);
}
?>