Posted By

level09 on 08/18/09


Tagged


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

vali29
luman
unitechy
rickfu
umang_nine
ReeceMarsland


Convert URLs to hyperlinks


 / Published in: PHP
 

  1. function makeClickableLinks($text) {
  2. $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)',
  3. '<a href="\1">\1</a>', $text);
  4. $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)',
  5. '\1<a href="http://\2">\2</a>', $text);
  6. $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})',
  7. '<a href="mailto:\1">\1</a>', $text);
  8.  
  9. return $text;
  10. }

Report this snippet  

You need to login to post a comment.