views:

62

answers:

2

How can i remove a new line character from a string using php.

+3  A: 
$string = str_replace("\n", "", $string);
$string = str_replace("\r", "", $string);
Harmen
+1  A: 
$string = str_replace(PHP_EOL, '', $string);

or

$string = str_replace(array("\n","\r\n"), '', $string);
AntonioCS