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));
Code language: PHP (php)
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments