<?php function makeClickableLinks($text) { $text = eregi_replace('(((f|ht){1}tp://)[[email protected]:%_+.~#?&//=]+)', '<a href="\1">\1</a>', $text); $text = eregi_replace('([[:space:]()[{}])(www.[[email protected]:%_+.~#?&//=]+)', '\1<a href="http://\2">\2</a>', $text); $text = eregi_replace('([_.0-9a-z-][email protected]([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '<a href="mailto:\1">\1</a>', $text); return $text; } // Usage // Email address example $text = "[email protected]"; echo makeClickableLinks($text); echo " "; // URL example $text = "http://www.example.com"; echo makeClickableLinks($text); echo " "; // FTP URL example $text = "ftp://ftp.example.com"; echo makeClickableLinks($text); ?>
Convert links into clickable hyperlinks
Page 1 of 10 Replies - 360 Views - Last Post: 21 May 2007 - 04:41 AM
#1
Convert links into clickable hyperlinks
Posted 21 May 2007 - 04:41 AM
Description: A function to change an email address or URL into a clickable HTML hyperlink using eregi_replace.
Page 1 of 1