A little dab'll do ya
Code Snippets
Convert BR to Newline
Technique #1
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;
}Converts a break tag to a newline - no matter what kind of HTML is being processed.
Technique #2
function br2nl( $input ) {
return preg_replace('/<br(\s+)?\/?>/i', "\n", $input);
}
Technique #2 will work a lot better than #1
But in #1, you could just use the first three calls and use str_ireplace() instead.
I’m suffered a lot. A used ” but I should use ‘. Could it be really a mistake?