Edit: The problem described below was just caused by a "feature" of my IDE, so there's actually nothing wrong with the regex. If you're interested in how to double line breaks, here's your question and answer in one neat package. :)
I want to change every line break in a string to be two line breaks:
"this is
an example
string"
// becomes:
"this is
an example
string"
However, it needs to take Unix/Windows line endings into account. I've written the code below, but it's not behaving itself.
$output = preg_replace("/(\r?\n)/", "$1$1", $input);
But it's not working. Changing the replacement string to this...
"$1 $1"
...makes it work, but then I have an unwanted space in between.