php turn unicode http link into clickable

Posted by newinjs on Stack Overflow See other posts from Stack Overflow or by newinjs
Published on 2010-06-06T07:07:51Z Indexed on 2010/06/06 7:12 UTC
Read the original article Hit count: 296

Filed under:

Hello, i have unicode link needed to be turn into links.

Is it possible to change unicode into clickable?

Currently i'm using this piece of code to turn link into clickable

function clickable_link($text)
{
$ret = ' ' . $text;
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a class=\"hrefLink\" href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a class=\"hrefLink\" href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
$ret = substr($ret, 1);
return $ret;
} 

Any help would be deeply appreciated.

© Stack Overflow or respective owner

Related posts about php