Text to HTML conversion
PHP function for plain text to HTML conversion.
Source code:
<?
function txt2html($txt){
$txt = preg_replace("/([a-z0-9\._-]+)@([a-z0-9\.-]+)\.([a-z]{2,3})/i", "<a href='mailto:$1@$2.$3'>$1@$2.$3</a>", $txt);
$txt = preg_replace("/(\s)http:\/\/(.+)(\s)/i", "$1<a href='http://$2'>http://$2</a>$3", $txt);
$txt = preg_replace("/(\s)www\.(.+)(\s)/i", "$1<a href='http://www.$2'>www.$2</a>$3", $txt);
$txt = nl2br($txt);
$txt = preg_replace("/\s{2}/", " ", $txt);
$txt = "<div style='font-family: \"Courier New\", Courier, monospace; font-size: 12px;'>{$txt}</div>";
return $txt;
}
?>


