It works!
Although I had to remove the 'g' from the regex because it didn't recognize it:
$html = preg_replace (
'/<a ([>]+)>/i',
'<a \1 target="_blank">',
$html
);
Thanks Lux.
I have another problem that I need to convert every "\n" to "<br>" only if there is no </P> before it:
e.g
"</P>\n" => "</P>\n" (no change)
"\n" => "<br>"
I can convert the whole string to something else like "{}", then convert all "\n" and then convert the "{}" back to its original form, but I'm looking for a simpler way that uses a single command.
Is there any way of doing this?