Convert BR to Newline
Technique #1
Converts a break tag to a newline - no matter what kind of HTML is being processed.
function br2newline( $input ) { $out = str_replace( "<br>", "\n", $input ); $out = str_replace( "<br/>", "\n", $out ); $out = str_replace( "<br />", "\n", $out ); $out = str_replace( "<BR>", "\n", $out ); $out = str_replace( "<BR/>", "\n", $out ); $out = str_replace( "<BR />", "\n", $out ); return $out; }
Technique #2
function br2nl( $input ) { return preg_replace('/<br(\s+)?\/?>/i', "\n", $input); }
No comments:
Post a Comment