Auto Link Maker

Description: Automatically make active links to URLs. Works for both ‘http:’ and ‘mailto:’ links.

<?PHP
 
FUNCTION change_string($str){
     $str = TRIM($str);
     $str = HTMLSPECIALCHARS($str);
     $str = PREG_REPLACE('#(.*)\@(.*)\.(.*)#','<a href="mailto:\\1@\\2.\\3">Send email</a>',$str);
     $str = PREG_REPLACE('=([^\s]*)(www.)([^\s]*)=','<a href="http://\\2\\3" target=\'_new\'>\\2\\3</a>',$str);
     RETURN $str;
   }
 
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.