src/Utilities/Uri.php
public static function getUserWebBrowserName($withVersion = false)
    {
        $info = self::getUserWebBrowserInfo();

        $knownBrowsers = [
            'Firefox/([\d\.]+)$' => 'Mozilla Firefox',
            'OPR/([\d\.]+)$'     => 'Opera',
            'Chrome/([\d\.]+)$'  => 'Google Chrome',
            'Safari/([\d\.]+)$'  => 'Apple Safari',
        ];

        foreach ($knownBrowsers as $pattern => $browserName) {
            $matches = [];
            $matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches);

            if ($matchCount > 0) {
                if ($withVersion) {
                    $version = $matches[1];

                    return sprintf('%s %s', $browserName, $version);
                }

                return $browserName;
            }
        }

        return '';
    }
public static function getUserWebBrowserName($withVersion = false)
    {
        $info = self::getUserWebBrowserInfo();

        $knownBrowsers = [
            'Firefox/([\d\.]+)$' => 'Mozilla Firefox',
            'OPR/([\d\.]+)$'     => 'Opera',
            'Chrome/([\d\.]+)$'  => 'Google Chrome',
            'Safari/([\d\.]+)$'  => 'Apple Safari',
        ];

        foreach ($knownBrowsers as $pattern => $browserName) {
            $matches = [];
            $matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches);

            if ($matchCount > 0) {
                if ($withVersion) {
                    $version = $matches[1];

                    return sprintf('%s %s', $browserName, $version);
                }

                return $browserName;
            }
        }

        return '';
    }
public static function getUserWebBrowserName ( $ withVersion = false ) { $ info = self :: getUserWebBrowserInfo ( ) ; $ knownBrowsers = [ 'Firefox/([\d\.]+)$' => 'Mozilla Firefox' , 'OPR/([\d\.]+)$' => 'Opera' , 'Chrome/([\d\.]+)$' => 'Google Chrome' , 'Safari/([\d\.]+)$' => 'Apple Safari' , ] ; foreach ( $ knownBrowsers as $ pattern => $ browserName ) { $ matches = [ ] ; $ matchCount = preg_match ( sprintf ( '|%s|' , $ pattern ) , $ info , $ matches ) ; if ( $ matchCount > 0 ) { if ( $ withVersion ) { $ version = $ matches [ 1 ] ; return sprintf ( '%s %s' , $ browserName , $ version ) ; } return $ browserName ; } } return '' ; }
Returns name and version of user's web browser

@param bool $withVersion (optional) If is set to true, version of the browser is returned too. Otherwise -
name only.
@return string
Returns name and version of user s web browser