Php user-defined function br2nl converts the br line breaks in html to line breaks in text input [opposite to the nl2br function ],
This example describes how to use the php user-defined function br2nl to convert the br line breaks in html to line breaks in text input. We will share this with you for your reference. The details are as follows:
The following methods can help you solve this problem.
PHP converts <br/> line breaks in html to line breaks in the text box:
The Code is as follows:
Function br2nl ($ text) {return preg_replace ('/<br \ s *? \ // ???> /I ', '', $ text );}
Or
The Code is as follows:
Function br2nl ($ text) {$ text = preg_replace ('/<br \ s *? \ // ???> /I ', chr (13), $ text); return preg_replace (' // I ', '', $ text );}
Appendix:
JS version converts <br/> line breaks in html to line breaks in the text box:
The Code is as follows:
Function br2nl (txt) {var re =/(<br \/> | <br> | <BR \/>)/g; var s = txt. replace (re, "\ n"); return s ;}