PHP code example of toobo / bcp47
1. Go to this page and download the library: Download toobo/bcp47 library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
toobo / bcp47 example snippets
$isValid = Toobo\Bcp47::isValidTag('i-klingon'); // true
$isValid = Toobo\Bcp47::isValidTag('xy'); // false
$filtered = Toobo\Bcp47::filterTag('EN-us'); // "en-US"
$filtered = Toobo\Bcp47::filterTag('fr-latn-fx'); // "fr-FR"
$isRTL = Toobo\Bcp47::isRtl('he'); // true
$isRTL = Toobo\Bcp47::isRtl('en-us'); // false
var_export(Toobo\Bcp47::splitTag('En-ca-Newfound'));
array (
'language' => 'en',
'extLang' => '',
'script' => '',
'region' => 'CA',
'variant' => 'newfound',
'extension' => '',
'privateUse' => '',
)
$tag = Toobo\Bcp47Tag::new('En-ca-Newfound');
assert($tag->isSameCodeAs(Toobo\Bcp47Tag::new('en-CA-newfound')) === true);
assert($tag->language() === 'en');
assert($tag->extLang() === null);
assert($tag->script() === null);
assert($tag->region() === 'CA');
assert($tag->variant() === 'newfound');
assert($tag->extension() === null);
assert($tag->privateUse() === null);
assert($tag->isRtl() === false);
assert((string) $tag === 'en-CA-newfound');
assert($tag->toBcp47Code() === 'en-CA-newfound');
assert(json_encode($tag) === '{"language":"en","region":"CA","variant":"newfound"}');