how can I replace newlines with br in php?

I'm trying to have it parse the input from a form, I want users to be able to enter line breaks in the form, and have the output to be one line. what I'm trying to do is have the PHP script make a js file with a bunch of array entries that's used in a different part of the site. so the line breaks have to be taken out.
I tried to use str_ireplace and told to to replace all \n characters with <br> ones.
but it doesn't quite work like I want. is there a better function or something else I'm missing here?
given the input:
Line one
Line two
I want it to return:
Line one<br>Line two
but I get:
Line one<br>
Line two
 
Back
Top