src/Agent.php
public function languages($acceptLanguage = null)
    {
        if ($acceptLanguage === null) {
            $acceptLanguage = $this->getHttpHeader('HTTP_ACCEPT_LANGUAGE');
        }

        if (!$acceptLanguage) {
            return [];
        }

        $languages = [];

        // Parse accept language string.
        foreach (explode(',', $acceptLanguage) as $piece) {
            $parts = explode(';', $piece);
            $language = strtolower($parts[0]);
            $priority = empty($parts[1]) ? 1. : floatval(str_replace('q=', '', $parts[1]));

            $languages[$language] = $priority;
        }

        // Sort languages by priority.
        arsort($languages);

        return array_keys($languages);
    }
public function languages($acceptLanguage = null)
    {
        if ($acceptLanguage === null) {
            $acceptLanguage = $this->getHttpHeader('HTTP_ACCEPT_LANGUAGE');
        }

        if (!$acceptLanguage) {
            return [];
        }

        $languages = [];

        // Parse accept language string.
        foreach (explode(',', $acceptLanguage) as $piece) {
            $parts = explode(';', $piece);
            $language = strtolower($parts[0]);
            $priority = empty($parts[1]) ? 1. : floatval(str_replace('q=', '', $parts[1]));

            $languages[$language] = $priority;
        }

        // Sort languages by priority.
        arsort($languages);

        return array_keys($languages);
    }
public function languages ( $ acceptLanguage = null ) { if ( $ acceptLanguage === null ) { $ acceptLanguage = $ this -> getHttpHeader ( 'HTTP_ACCEPT_LANGUAGE' ) ; } if ( ! $ acceptLanguage ) { return [ ] ; } $ languages = [ ] ; // Parse accept language string. foreach ( explode ( ',' , $ acceptLanguage ) as $ piece ) { $ parts = explode ( ';' , $ piece ) ; $ language = strtolower ( $ parts [ 0 ] ) ; $ priority = empty ( $ parts [ 1 ] ) ? 1. : floatval ( str_replace ( 'q=' , '' , $ parts [ 1 ] ) ) ; $ languages [ $ language ] = $ priority ; } // Sort languages by priority. arsort ( $ languages ) ; return array_keys ( $ languages ) ; }
Get accept languages.
@param string $acceptLanguage
@return array
Get accept languages .