php - replace string occurrences

php, string

Solution

here it is

str_replace('|',"\n",$string);

when \n is placed in double qouted string it changes to a new line

Problem

I have a string `"First line | second line | third line"` How can I replace `|` with a `new line` character? I'm trying to use `preg_replace` but with no liuck

Original source