Posted By

mscribellito on 01/18/12


Tagged


Versions (?)

Linkify


 / Published in: PHP
 

Turns links in plain text into a clickable link

  1. function linkify($subject) {
  2.  
  3. $pattern = "/(http:\/\/)?([a-zA-Z0-9\-.]+\.[a-zA-Z0-9\-]+([\/]([a-zA-Z0-9_\/\-.?&%=+])*)*)/";
  4. $replace = "<a href=\"http://$2\">$2</a>";
  5.  
  6. return preg_replace($pattern, $replace, $subject);
  7.  
  8. }

Report this snippet  

You need to login to post a comment.