PHPBuilder - How to make linebreaks \n s...

RSS Twitter

How to make linebreaks \n s...

by: Chris Heilmann
February 9, 2001

I had the following thing to achieve:
for a Homesite extension, I needed the data of a textarea to be put in a textfield and all real linebreaks to become \n ...

Sound easy but was quite a pain, as I tried to make a nl2br and change the br's back to \n, no can do, as PHP surrounds them by linebreaks.

Now the solution is ridiculously easy:

I am sure there is some nifty regular expression as well, but that's how I got lucky.
No rocket science, but hey...

Comment and Contribute

Your comment has been submitted and is pending approval.

Chris Heilmann



(Maximum characters: 1200). You have characters left.