I have this interesting function that I\'m using to create new lines into paragraphs. I\'m using it instead of the nl2br()
function, as it outputs better formatted
Expanding upon @NaturalBornCamper's solution:
function nl2p( $text, $class = '' ) {
$string = str_replace( array( "\r\n\r\n", "\n\n" ), '', $text);
$string = str_replace( array( "\r\n", "\n" ), '
', $string);
return '
' . $string . '
';
}
This takes care of both double line breaks by converting them to paragraphs, and single line breaks by converting them to