Have an account? Sign in
Login  Register  Facebook
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
[Edit] convert link and username text into links

Turn link and @username text into links

Save 6,243 link
function rich_str($text)
{
    $hyperlink = "/(http:\/\/\S+)/";
        if(preg_match($hyperlink, $text))
        {
            $text = preg_replace($hyperlink, "<a href='$1'>$1</a>", $text);
        }

    $userlink = "/@([^()#@\s\,]+)/";
        if(preg_match($userlink, $text))
        {
            $text = preg_replace($userlink, 
                "<a href='http://site.com/$1'>@$1</a>"
            , $text);
        }
return $text;
}