Monday, April 20, 2009

Remove new line CRLF (\r\n) or line break

Removing the new line tags (CRLF) from a string

$string = "some thing new
line one
line two";

$new_string = preg_replace("/\r\n/", " ", $string);

you may also replace the line break with
tag as following

$new_string = preg_replace("/\r\n/", "
", $string);