×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
1
Language: PHP
Posted by: Massimo Zappino
Added: Jan 31, 2011 7:36 AM
Modified: May 6, 2016 12:35 PM
Views: 187
This method identifies clickable url and wraps them with A tag
  1. function clickable_urls($text = '')
  2. {
  3.    $pattern = '#(^|[^\"=]{1})(http://|https://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm';
  4.    return preg_replace($pattern, "\\1<a href=\"\\2\\3\" target=\"_blank\"><u>\\2\\3</u></a>\\4", $text);
  5. }