how to remove new lines and returns from php string?
You have to wrap \n
or \r
in ""
, not ''
. When using single quotes escape sequences will not be interpreted (except \'
and \\
).
If the string is enclosed in double-quotes ("), PHP will interpretmore escape sequences for special characters:
\n linefeed (LF or 0x0A (10) in ASCII)
\r carriage return (CR or 0x0D (13) in ASCII)\
(...)