Remove all new line characters

To remove all new line characters from a string, use a regular expressions with a couple other PHP functions:

$output = trim(preg_replace('/\s+/', ' ', $input));