$string = "
put returns between paragraphs
for linebreak add 2 spaces at end
";
Want to remove all new lines from string.
I've this regex, it can catch all of them, the problem is I don't know with which function should I use it.
/\r\n|\r|\n/
$string
should become:
$string = "put returns between paragraphs for linebreak add 2 spaces at end ";
preg_replace
. It is almost twice as slow asstr_replace
. – Alex Ws($str)->normalizeLineEndings('')
helpful, as found in this standalone library. It will remove not only LF, CR and CRLF, but also any Unicode newline. – caw