Remove All Linebreaks in PHP


If you are having problems with a string that keeps adding a line break when output from PHP to HTML then the following code will work wonders for you!

$string_with_line_break = "blabla\nbla\r";
$string_without_line_break = trim(preg_replace( "/\s+/","",$string_with_line_break));