Let's say I typed in a <textarea> :

Then I save it to myphpadmin database. Then I use mysql to retrieve it from database and display it onto a <div>. Now the output that show in the <div> is :
I Love You

How to make the <div> show exactly like the database field and textarea which has multiple rows?

My question here. I did try to use css white-space:pre; but it is not working on IE7 and IE5. So I tried to find another solution which replace all new line / new row with <br> tag, I found the solution from here. Here is the codes :

or use php str_replace :
$value = "I

$order = array("\r\n", "\n", "\r"); $gg = str_replace($order , "
", $value);

Posted by Zac1987 on 21 January, 2012

1 Comment

  1. Thank you for the fantastic article. The place else could anyone get that kind of info in such a perfect means of writing? I have a presentation next week, and I am at the search for such information.

    Posted on 12:37 PM, July 21, 2012


Enter your email address:

Subscribe in a reader

Follow zac1987 on Twitter

Chatting Box


If you feel my website is informative and it is useful for you, please donate some money to support me or buy me a drink. I will continues this good works. Thank you.