You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will return an instance of `\CodeZero\BrowserLocale\Locale` or `null` if no locale exists.
71
55
72
-
```php
56
+
```php
73
57
if ($locale !== null) {
74
58
$full = $locale->locale; // Example: "en-US"
75
59
$language = $locale->language; // Example: "en"
@@ -84,11 +68,12 @@ if ($locale !== null) {
84
68
$locales = $browser->getLocales();
85
69
```
86
70
87
-
This will return an array of `\CodeZero\BrowserLocale\Locale` instances, sorted by weight in descending order. So the first array item is the most preferred locale.
71
+
This will return an array of `\CodeZero\BrowserLocale\Locale` instances, sorted by weight in descending order.
72
+
So the first array item is the most preferred locale.
88
73
89
74
If no locales exist, an empty array will be returned.
90
75
91
-
```php
76
+
```php
92
77
foreach ($locales as $locale) {
93
78
$full = $locale->locale; // Example: "en-US"
94
79
$language = $locale->language; // Example: "en"
@@ -99,59 +84,61 @@ foreach ($locales as $locale) {
99
84
100
85
## Filter Locale Info
101
86
102
-
You can get a flattened array with only specific Locale information. These arrays will always be sorted by weight in descending order. There will be no duplicate values! (e.g. `en` and `en-US` are both the language `en`)
87
+
You can get a flattened array with only specific Locale information.
88
+
These arrays will always be sorted by weight in descending order.
89
+
There will be no duplicate values! (e.g. `en` and `en-US` are both the language `en`)
103
90
104
-
####LocaleFilter
91
+
### LocaleFilter
105
92
106
93
Returns an array of every locale found in the input string.
107
94
108
-
```php
95
+
```php
109
96
$browser = new \CodeZero\BrowserLocale\BrowserLocale('en-US,en;q=0.8,nl-NL;q=0.6');
$filter = new \CodeZero\BrowserLocale\Filters\CombinedFilter;
122
109
$locales = $browser->filter($filter);
123
110
//=> Result: ['en-US', 'en', 'nl']
124
111
```
125
112
126
-
####LanguageFilter
113
+
### LanguageFilter
127
114
128
115
Returns an array of only the 2-letter language codes found in the input string. Language codes are also extracted from full locales and added to the results array.
129
116
130
-
```php
117
+
```php
131
118
$browser = new \CodeZero\BrowserLocale\BrowserLocale('en-US,en;q=0.8,nl-NL;q=0.6');
0 commit comments