library/Garp/Util/String.php
static public function linkUrls($text, array $attribs = array()) {
        $htmlAttribs = array();
        foreach ($attribs as $name => $value) {
            $htmlAttribs[] = $name . '="' . $value . '"';
        }
        $htmlAttribs = implode(' ', $htmlAttribs);
        $htmlAttribs = $htmlAttribs ? ' ' . $htmlAttribs : '';

        $regexpProtocol = "/(?:^|\s)((http|https|ftp):\/\/[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i";
        $regexpWww      = "/(?:^|\s)((www\.)[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i";

        $text = preg_replace($regexpProtocol, " <a href=\"\\1\"$htmlAttribs>\\1</a>\\3 ", $text);
        $text = preg_replace($regexpWww, " <a href=\"http://\\1\"$htmlAttribs>\\1</a>\\3 ", $text);
        return trim($text);
    }
static public function linkUrls($text, array $attribs = array()) {
        $htmlAttribs = array();
        foreach ($attribs as $name => $value) {
            $htmlAttribs[] = $name . '="' . $value . '"';
        }
        $htmlAttribs = implode(' ', $htmlAttribs);
        $htmlAttribs = $htmlAttribs ? ' ' . $htmlAttribs : '';

        $regexpProtocol = "/(?:^|\s)((http|https|ftp):\/\/[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i";
        $regexpWww      = "/(?:^|\s)((www\.)[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i";

        $text = preg_replace($regexpProtocol, " <a href=\"\\1\"$htmlAttribs>\\1</a>\\3 ", $text);
        $text = preg_replace($regexpWww, " <a href=\"http://\\1\"$htmlAttribs>\\1</a>\\3 ", $text);
        return trim($text);
    }
static public function linkUrls ( $ text , array $ attribs = array ( ) ) { $ htmlAttribs = array ( ) ; foreach ( $ attribs as $ name => $ value ) { $ htmlAttribs [ ] = $ name . '="' . $ value . '"' ; } $ htmlAttribs = implode ( ' ' , $ htmlAttribs ) ; $ htmlAttribs = $ htmlAttribs ? ' ' . $ htmlAttribs : '' ; $ regexpProtocol = "/(?:^|\s)((http|https|ftp):\/\/[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i" ; $ regexpWww = "/(?:^|\s)((www\.)[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i" ; $ text = preg_replace ( $ regexpProtocol , " <a href=\"\\1\"$htmlAttribs>\\1</a>\\3 " , $ text ) ; $ text = preg_replace ( $ regexpWww , " <a href=\"http://\\1\"$htmlAttribs>\\1</a>\\3 " , $ text ) ; return trim ( $ text ) ; }
Link URLs.

@param string $text
@param array $attribs HTML attributes
@return string
Link URLs .