1. Go to this page and download the library: Download happyphper/country 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/ */
happyphper / country example snippets
use HappyPhper\Country\CountryCollection;
$collection = new CountryCollection();
$countries = $collection->getAll();
use HappyPhper\Country\CountryCollection;
$collection = new CountryCollection();
// 通过 ISO 3166-1 alpha-2 代码获取
$country = $collection->getByAlpha2('CN');
// 通过 ISO 3166-1 alpha-3 代码获取
$country = $collection->getByAlpha3('CHN');
// 通过 ISO 3166-1 numeric 代码获取
$country = $collection->getByNumeric('156');