A php variable contains the following string:
text text2 item1 item2
text
text2
$no_newlines = str_replace("\r", '', str_replace("\n", '', $str_with_newlines));