Strip, remove, trim new line in PHP?

Strip, remove, trim new line in PHP?

Use this code:

1
str_replace(array("\r", "\n"), '', $string)

Something like this:

2
$yourstring = str_replace(array("\r", "\n"), '', $yourstring)

This will remove all the weird unwanted new lines from your string.

Add a comment: