For a user input I do this:
$var=str_replace(array('\r','\n'),'',$var);
Works well on Windows, removing any new lines.
However, on the Mac (+Firefox) it somehow replaces the new lines with a \
开发者_StackOverflow中文版character.
Any clues as to why that happens?
I'm surprised it works on Windows.
Usually, for PHP to interpret control characters, they need to be in double-quoted strings, eg
array("\r", "\n")
set the value auto_detect_line_endings
to on in php.ini
file
or ini_set("auto_detect_line_endings", true);
精彩评论