I am looking for the best br2nl function. I would like to replace all instances of and <br> with newlines <br />\n. Much like the nl2br() function but the opposite.
I know there are several solutions in the PHP manual comments but I’m looking for feedback from the SO community on possible solutions.
I would generally say “don’t use regex to work with HTML“, but, on this one, I would probably go with a regex, considering that
<br>tags generally look like either :<br><br/>, with any number of spaces before the/I suppose something like this would do the trick :
Couple of notes :
<br\s*/:/?>#i), as<BR>would be valid in HTML