php如何在视图上建立URL链接

i did one chat application ,

in the my chat pings area am displaying my pings, if i enter url that is displaying as TEXT but instead i want to display as URL ,

How to display url are Link the view,

Advise...

Example ,

x says:hi Good Morning,
y says:Hi GM,
x says:Chk this www.happylife.in ,(instead text i want to show www.happylife.in  URL or LINK)
y says:yes sure
$chat = "Chk this http://www.happylife.in";
$chat = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</A>", $chat);