PX : code

Hyperlink Encoder by Mark Young
Download this code


<?
function HTMLEncode($text)
{
  $searcharray =  array(
     \"\'([-_\\w\\d.]+@[-_\\w\\d.]+)\'\", //look for e-mail addr
     \"\'((?:(?!://).{3}|^.{0,2}))(www\\.[-\\d\\w\\.\\/]+)\'\",  //look for \"www.something...\", not preceeded by http
     \"\'(http[s]?:\\/\\/[-=&_~\\?\\w\\d\\.\\/]+)\'\");  //look for \"http://www.something...\"
  $replacearray = array(
     \"<a href=\\\"mailto:\\\\1\\\">\\\\1</a>\",  //add \"mailto:\" tags
     \"\\\\1http://\\\\2\",   //prefix with \"http://\"
     \"<a href=\\\"\\\\1\\\" target=\\\"_new\\\">\\\\1</a>\");   //add \"href\" tags
  return nl2br(preg_replace($searcharray, $replacearray, stripslashes($text) ));
}

?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.