Turn Static URLs Into Links

/ Published in: PHP
Save to your folder(s)

Nice simple snippet. Great for forum scripts.

Copy this code and paste it in your HTML
  1. function linkify($url){
  2. $string = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target=\"_blank\">\\0</a>", $url);
  3. return $string;
  4. }

URL: http://www.imben.co.uk

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.