php line break insertion

Sic

Sic

Soldato
Joined
9 Nov 2004
Posts
15,365
Location
SO16
i've just realised that i've got an issue when people are posting comments on my site, user line breaks aren't showing so the comments are looking pretty jumbled. what do i need to do to convert a user entered line break (when they press return) into an html <br />? i'm guessing it's str_replace(), but what i was trying hasn't worked.

i've been trying str_replace("\n","<br />","$body"), but it's not working

can anyone shed some light?

thanks :)
 
i want to use something like Dj_Jestar's, but it's not working. if i pass the following through a text field:

test
test
test

it comes out as

testtesttest

what could this be? i'm wasting far too much time on this when it's probably really simple!

i've tried \r\n, \n, \r and \n\n so far and none of those have been replaced with what i want. i'd be really grateful for some help :)
 
Back
Top Bottom