Which php function should i use?

i have users entering news articles into a db. when the articles are printed back out, i need a return to be replaced with a </p><p> to end the last paragraph and being a new one.

so what php function should i used to locate a return and insert </p><p>? basically i want it to function just like a post in this forum in that sense.