I have a string \"First line | second line | third line\" How can I replace | with a new line character?
\"First line | second line | third line\"
|
new line
I\'m trying to use
Use this:
str_replace('|', PHP_EOL, $str);
You should use PHP_EOL instead of "\n" because PHP_EOL will always work on all server platforms. (NB. Windows uses "\r\n" and unix/linux uses "\n").
PHP_EOL
"\n"
"\r\n"