1. Go to this page and download the library: Download tourze/gb-t-4880 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/ */
tourze / gb-t-4880 example snippets
use Tourze\GBT4880\Alpha2Code;
// Get language code
$code = Alpha2Code::Chinese->value; // 'zh'
// Get Chinese label
$name = Alpha2Code::Chinese->getLabel(); // '汉语'
// Check if languages are the same
$isSame = Alpha2Code::Chinese === Alpha2Code::from('zh'); // true
// Get all language codes
foreach (Alpha2Code::cases() as $language) {
echo $language->value . ' => ' . $language->getLabel() . PHP_EOL;
}
// Filter languages (example: find all languages containing '语')
$languages = array_filter(Alpha2Code::cases(), function($lang) {
return str_contains($lang->getLabel(), '语');
});
// Works with form builders
$selectOptions = Alpha2Code::genOptions();
// Works with validation
$isValid = Alpha2Code::tryFrom($userInput) !== null;
// Works with serialization
$jsonData = json_encode(Alpha2Code::Chinese->toArray());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.