带换行符的str_replace? [关闭]

I'm trying to replace a regular expression with a line break. Right now I'm trying this which doesn't work:

$string = str_replace(';', '
', $string);

I need to make sure that semi colons are exactly the same as ' ' line breaks, how can I get this done?

Use double quotes, otherwise is not parsed. Documentation

$string = str_replace(';', " ", $string);

Try this :

str_replace :

$string = str_replace(';', "
", $string);
echo $string;

preg_replace :

$string  = 'sdasdasd;asdasd;asdasd';

$string1 = preg_replace("/;/","
",$string);
echo nl2br($string1);