function add_html_links($string) { //Make links beginning with 'ftp://' or 'http://' $string = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1">\1</a>', $string); //Make links beginning with 'www.' $string = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1<a href="http://\2">\2</a>', $string); //Make mailto: links out of text that is in email format $string = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '<a href="mailto:\1">\1</a>', $string); return $string; }
Enjoy :)
Thank you! This was just what I was looking for!
ReplyDeleteUse preg_replace against eregi_replace because of it's a deprecated function
ReplyDelete