Opposite of nl2br? Is it str_replace?
- by Julian H. Lam
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.
str_replace can take <br /> and replace it with whatever I want, but if I put in \n, it echoes literally a backslash and an n. It only works if I put a literal line break in the middle of my script, and break the indentation (so there are no trailing space).
See:
<?=str_replace('<br />','
',$foo)?>
Am I missing escape characters? I think I tried every combination...