PHP code example of arslanimamutdinov / iso-standard-3166

1. Go to this page and download the library: Download arslanimamutdinov/iso-standard-3166 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/ */

    

arslanimamutdinov / iso-standard-3166 example snippets


composer 

public function getName(): string;

$country = ISO3166::RU();
$name = $country->getName();

string(18) "Russian Federation"

public function getAlpha2(): string;

$country = ISO3166::RU();
$alpha2 = $country->getAlpha2();

string(2) "RU"

public function getAlpha3(): string;

$country = ISO3166::RU();
$alpha3 = $country->getAlpha3();

string(3) "RUS"

public function getNumericCode(): string;

$country = ISO3166::RU();
$numericCode = $country->getNumericCode();

string(3) "643"

/**
 * @return Country[]
 */
public static function getAll(): array;

/**
 * @return Country[]
 */
public function getAll(): array;

$countries = ISO3166::getAll();
$countries = (new ISO3166Utility())->getAll();

{
...
[248]=>
  object(arslanimamutdinov\ISOStandard3166\Country)#251 (4) {
    ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(8) "Zimbabwe"
    ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(2) "ZW"
    ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "ZWE"
    ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "716"
  }
}

/**
 * @param string[] $alpha2Codes
 * @return Country[]
 */
public static function getAllByAlpha2Codes(array $alpha2Codes): array;

/**
 * @param string[] $alpha2Codes
 * @return Country[]
 */
public function getAllByAlpha2Codes(array $alpha2Codes): array;

$countries = ISO3166::getAllByAlpha2Codes(['RU', 'BY']);
$countries = (new ISO3166Utility())->getAllByAlpha2Codes(['RU', 'BY']);

array(2) {
  [0]=>
      object(arslanimamutdinov\ISOStandard3166\Country)#2 (4) {
        ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(7) "Belarus"
        ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(2) "BY"
        ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(3) "BLR"
        ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(3) "112"
      }
  [1]=>
      object(arslanimamutdinov\ISOStandard3166\Country)#4 (4) {
        ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(18) "Russian Federation"
        ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(2) "RU"
        ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(3) "RUS"
        ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(3) "643"
      }
}

/**
 * @param string[] $alpha3Codes
 * @return Country[]
 */
public static function getAllByAlpha3Codes(array $alpha3Codes): array;

/**
 * @param string[] $alpha3Codes
 * @return Country[]
 */
public function getAllByAlpha3Codes(array $alpha3Codes): array;

$countries = ISO3166::getAllByAlpha3Codes(['RUS', 'BLR']);
$countries = (new ISO3166Utility())->getAllByAlpha3Codes(['RUS', 'BLR']);

array(2) {
  [0]=>
      object(arslanimamutdinov\ISOStandard3166\Country)#4 (4) {
        ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(7) "Belarus"
        ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(2) "BY"
        ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(3) "BLR"
        ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(3) "112"
      }
  [1]=>
      object(arslanimamutdinov\ISOStandard3166\Country)#5 (4) {
        ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(18) "Russian Federation"
        ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(2) "RU"
        ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(3) "RUS"
        ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
        string(3) "643"
      }
}

/**
 * @param string[] $numericCodes
 * @return Country[]
 */
public static function getAllByNumericCodes(array $numericCodes): array;

/**
 * @param string[] $numericCodes
 * @return Country[]
 */
public function getAllByNumericCodes(array $numericCodes): array;

$countries = ISO3166::getAllByNumericCodes(['826', '840']);
$countries = (new ISO3166Utility())->getAllByNumericCodes(['826', '840']);

array(2) {
  [0]=>
  object(arslanimamutdinov\ISOStandard3166\Country)#4 (4) {
    ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(52) "United Kingdom of Great Britain and Northern Ireland"
    ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(2) "GB"
    ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "GBR"
    ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "826"
  }
  [1]=>
  object(arslanimamutdinov\ISOStandard3166\Country)#5 (4) {
    ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(24) "United States of America"
    ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(2) "US"
    ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "USA"
    ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "840"
  }
}

/**
 * @param string[] $names
 * @return Country[]
 */
public static function getAllByNames(array $names): array;

/**
 * @param string[] $names
 * @return Country[]
 */
public function getAllByNames(array $names): array;

$countries = ISO3166::getAllByNames(['Sudan', 'Panama']);
$countries = (new ISO3166Utility())->getAllByNames(['Sudan', 'Panama']);

array(2) {
  [0]=>
  object(arslanimamutdinov\ISOStandard3166\Country)#4 (4) {
    ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(6) "Panama"
    ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(2) "PA"
    ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "PAN"
    ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "591"
  }
  [1]=>
  object(arslanimamutdinov\ISOStandard3166\Country)#5 (4) {
    ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(5) "Sudan"
    ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(2) "SD"
    ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "SDN"
    ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
    string(3) "729"
  }
}

public static function getRawStandardsData(): array;

public function getRawStandardsData(): array;

$countriesRawData = ISO3166::getRawStandardsData();
$countriesRawData = (new ISO3166Utility())->getRawStandardsData();

{
  ...
  [246]=>
  array(4) {
    ["name"]=>
    string(5) "Yemen"
    ["alpha2"]=>
    string(2) "YE"
    ["alpha3"]=>
    string(3) "YEM"
    ["numericCode"]=>
    string(3) "887"
  }
  [247]=>
  array(4) {
    ["name"]=>
    string(6) "Zambia"
    ["alpha2"]=>
    string(2) "ZM"
    ["alpha3"]=>
    string(3) "ZMB"
    ["numericCode"]=>
    string(3) "894"
  }
  [248]=>
  array(4) {
    ["name"]=>
    string(8) "Zimbabwe"
    ["alpha2"]=>
    string(2) "ZW"
    ["alpha3"]=>
    string(3) "ZWE"
    ["numericCode"]=>
    string(3) "716"
  }
}

public static function getByAlpha2(string $alpha2): ?Country;

public function getByAlpha2(string $alpha2): ?Country;

$country = ISO3166::getByAlpha2('RU');
$country = (new ISO3166Utility())->getByAlpha2('RU');

object(arslanimamutdinov\ISOStandard3166\Country)#2 (4) {
  ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(18) "Russian Federation"
  ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(2) "RU"
  ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "RUS"
  ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "643"
}

public static function getByAlpha3(string $alpha3): ?Country;

public function getByAlpha3(string $alpha3): ?Country;

$country = ISO3166::getByAlpha3('RUS');
$country = (new ISO3166Utility())->getByAlpha3('RUS');

object(arslanimamutdinov\ISOStandard3166\Country)#2 (4) {
  ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(18) "Russian Federation"
  ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(2) "RU"
  ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "RUS"
  ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "643"
}

public static function getByNumericCode(string $numericCode): ?Country;

public function getByNumericCode(string $numericCode): ?Country;

$country = ISO3166::getByNumericCode('643');
$country = (new ISO3166Utility())->getByNumericCode('643');

object(arslanimamutdinov\ISOStandard3166\Country)#2 (4) {
  ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(18) "Russian Federation"
  ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(2) "RU"
  ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "RUS"
  ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "643"
}

$country = ISO3166::RU();
$country = ISO3166::US();
$country = (new ISO3166Utility())->RU();
$country = (new ISO3166Utility())->US();

object(arslanimamutdinov\ISOStandard3166\Country)#3 (4) {
  ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(18) "Russian Federation"
  ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(2) "RU"
  ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "RUS"
  ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "643"
}

object(arslanimamutdinov\ISOStandard3166\Country)#3 (4) {
  ["name":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(24) "United States of America"
  ["alpha2":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(2) "US"
  ["alpha3":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "USA"
  ["numericCode":"arslanimamutdinov\ISOStandard3166\Country":private]=>
  string(3) "840"
}