So the function nl2br is handy. Except in my web app, I want to do the opposite, interpret line breaks as new lines, since they will be echoed into a pre-filled form.
You'd want this:
=str_replace('',"\n",$foo)?>
You probably forgot to use double quotes. Strings are only parsed for special characters if you use double quotes.