I have the following string. I want to replace the line break with /n
Good FRIENDS are hard to find,<br
/> harder to leave,<br
/> and impossible to forget.
replace() method to replace all the line breaks in the plain text with the <br> tag. Here the RegEx refers to the regular expression that we write inside the string. replace() method.
The line break can be removed from string by using str_replace() function.
preg_replace("/<br\W*?\/>/", "\n", $your_string);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With