PHP code example of one23 / iso639

1. Go to this page and download the library: Download one23/iso639 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/ */

    

one23 / iso639 example snippets


use \One23\Iso639\Code1;
use \One23\Iso639\Code2b;
use \One23\Iso639\Code2t;
use \One23\Iso639\Code3;
// or
//use \One23\Iso639\Code3Min as Code3;

(string)Code1::from('en')->code3(); // => 'eng'
(string)Code1::from('uk')->getNameNative(); // => 'українська мова'
(string)Code1::from('jv')->getName(); // => 'Javanese'


(string)Code2t::from('eng')->getName(); // => 'English'
(string)Code2t::from('ind')->getNameNative(); // => 'Bahasa Indonesia'
(string)Code2t::from('jav')->code1(); // => 'jv'

use \One23\Iso639\Code1 as Code;
// or
//use \One23\Iso639\Code2b as Code;
// or
//use \One23\Iso639\Code2t as Code;

$code = Code::from('en');

(string)$code; // => 'en'
// or
$code->getCode(); // => 'en'
// or
$code->toString(); // => 'en'

$code->getName(); // => 'English'

$code->toArray();
// => "{"iso_639_1_code":"en","iso_639_1_name":"English","iso_639_1_native":"English","iso_639_1_notes":null,"iso_639_1_family":"Indo-European","is_ancient":false,"is_macrolanguage":false,"macrolanguages":[],"iso_639_2_t_code":"eng","iso_639_2_t_name":"English","iso_639_2_b_code":"eng","iso_639_2_b_name":"English","iso_639_3_code":"eng","iso_639_6_code":"engs"}

$code1 = Code2b::from('ara')->code1();
$macrolanguages = $code1->macrolanguages();

array_keys($macrolanguages); // => ["aao","abh","abv","acm","acq",...]
reset($macrolanguages); // Code3Macro

Code1::all(); // => ["ab","aa","af","ak",...]
Code2b::all(); // => ["abk","aar","afr","aka","alb","amh",...]
Code2t::all(); // => ["abk","aar","afr","aka","sqi","amh","ara","arg",...]

use \One23\Iso639\Code3;
// or
//use \One23\Iso639\Code3All as Code3;

$code3 = Code3::from('ful');

(string)$code3; // => 'ful'
// or
$code3->getCode(); // => 'ful'
// or
$code3->toString(); // => 'ful'

$code3->getName(); // => 'Fulah'

$code3->toArray();
// => {"iso_639_3_code":"ful","iso_639_3_name":"Fulah","iso_639_3_name_inverted":"Fulah","iso_639_3_scope":"M","iso_639_3_type":"L","iso_639_3_notes":null,"iso_639_1_code":"ff","iso_639_2_b_code":"ful","iso_639_2_t_code":"ful","iso_639_3_merge":null,"iso_639_3_merge_reason":null,"iso_639_3_merge_date":null}

$code3 = Code3All::from('xrq');

/** @var Code3All|null $merge **/
$merge = $code3->merge()
if ($merge) {
    $merge->toArray();
    // => {"iso_639_3_code":"dmw","iso_639_3_name":"Mudburra","iso_639_3_name_inverted":"Mudburra","iso_639_3_scope":"I","iso_639_3_type":"L","iso_639_3_notes":null,"iso_639_1_code":null,"iso_639_2_b_code":null,"iso_639_2_t_code":null,"iso_639_3_merge":null,"iso_639_3_merge_reason":null,"iso_639_3_merge_date":null}
}

Code3::all(); // => ["aka","ara","aym","aze","bal",...]

use \One23\Iso639\Code3Macro;

$code3Macro = Code3Macro::from('pmu');

(string)$code3Macro; // => 'pmu'
// or
$code3Macro->getCode(); // => 'pmu'
// or
$code3Macro->toString(); // => 'pmu'

$code3Macro->getName(); // => 'Mirpur Panjabi'

$code3Macro->toArray();
// => {"macrolanguage_code":"pmu","macrolanguage_name":"Mirpur Panjabi","macrolanguage_status":"R","macrolanguage_alias":"phr","iso_639_3_code":"lah"}

/** @var Code3Macro|null $parent **/
$alias = $code3Macro->alias()
if ($alias) {
    $alias->toArray();
    // => {"macrolanguage_code":"phr","macrolanguage_name":"Pahari-Potwari","macrolanguage_status":"A","macrolanguage_alias":null,"iso_639_3_code":"lah"}
}

Code3Macro::all(); // => ["fat","twi","aao","abh","abv","acm",...]

use \One23\Iso639\Code5;

$code5 = Code5::from('alg');

(string)$code5; // => 'alg'
// or
$code5->getCode(); // => 'alg'
// or
$code5->toString(); // => 'alg'

$code5->getName(); // => 'Algonquian languages'

$code5->toArray();
// => {"iso_639_5_code":"alg","iso_639_5_name":"Algonquian languages","iso_639_5_notes":null,"iso_639_5_parent":"aql","iso_639_2_t_code":"alg","iso_639_2_b_code":null}

/** @var Code5|null $parent **/
$parent = $code5->parent()
if ($parent) {
    $parent->toArray();
    // => {"iso_639_5_code":"aql","iso_639_5_name":"Algic languages","iso_639_5_notes":null,"iso_639_5_parent":"nai","iso_639_2_t_code":null,"iso_639_2_b_code":null}
}

Code5::all(); // => ["aav","afa","alg","alv","apa",...]


$code5 = Code5::from('aav');
$code5->getNotes(); // => 'South-Asiatic languages, not related to Australian languages'

use \One23\Iso639\Code6;

$code6 = Code6::from('tjin');

(string)$code6; // => 'tjin'
// or
$code6->getCode(); // => 'tjin'
// or
$code6->toString(); // => 'tjin'

$code6->getName(); // => 'Tianjin'

$code6->toArray(); 
// => {"iso_639_6_code":"tjin","iso_639_6_name":"Tianjin"}

Code6::all(); // => ["ango","bicr","bjgh","bjjg",...]