PHP code example of enadabuzaid / country-data

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

    

enadabuzaid / country-data example snippets


config('countries');

use CountryData; // via Facade

CountryData::getDialCodes(true);

[
  ['code' => 'JO', 'dial' => '+962', 'flag' => '🇯🇴', 'flag_url' => 'https://flagcdn.com/jo.svg'],
  ...
]

CountryData::getArabCountries();

CountryData::searchByName('السعودية', 'ar');

CountryData::getSelectOptions('en');
// => [ ['label' => 'Jordan', 'value' => 'JO'], ... ]
bash
php artisan vendor:publish --tag=country-data

config/
└── countries.php       # Published config data
src/
├── CountryData.php     # All logic methods
├── Facades/CountryData.php
└── CountryDataServiceProvider.php