ryantxr / browser-preferred-lang
Determines preferred language
1.0
2018-10-04 18:24 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: 6.*
This package is auto-updated.
Last update: 2025-03-18 19:29:52 UTC
README
This class will take $_SERVER['HTTP_ACCEPT_LANGUAGE'] and convert it into a list of languages/locales. The returned array is sorted by preference with the highest preference first in the list.
use Ryantxr\BrowserPreferredLang\PreferredLang; $p = new PreferredLang; $langs = $p->get(['en', 'zh-cn', 'es'], $_SERVER['HTTP_ACCEPT_LANGUAGE']); print_r($langs);
Output
(
[en] => 0.8
[es] => 0.4
[zh-cn] => 0.3
)
Installing
composer require ryantxr/browser-preferred-lang