PHP nl2p Function

Forget nl2br! With this nl2p function your content will be better formatted and code better presented.

1
2
3
4
5
6
7
function nl2p($string)
{
	$string = "<p>" . $string . "</p>";
	$string = preg_replace("/\r\n\r\n/", "</p>\n\n<p>", $string);
	$string = preg_replace("/\r\n/", "<br />", $string);
	return $string;
}

Tags:

Leave a Reply