A tiny PHP package to convert ISO 3166-1 alpha-2 country code to the country flag emoji Unicode character sequence.
For example, “RU” is converted to “🇷🇺”.
Install via Composer:
$ composer require sergeyakovlev/country-flag-emoji
require_once '/path_to_project/vendor/autoload.php';
use function SergeYakovlev\CountryFlagEmoji\country_flag_emoji;
// ISO Code: "RU"
// Output: "🇷🇺"
echo country_flag_emoji('RU'), PHP_EOL;
// or
echo country_flag_emoji('RU', null, null), PHP_EOL;
// or
echo country_flag_emoji('RU', '', ''), PHP_EOL;
// ISO Code: "RU"
// Extension Left: " "
// Output: " 🇷🇺"
echo country_flag_emoji('RU', ' '), PHP_EOL;
// or
echo country_flag_emoji('RU', ' ', null), PHP_EOL;
// or
echo country_flag_emoji('RU', ' ', ''), PHP_EOL;
// ISO Code: "RU"
// Extension Right: " "
// Output: "🇷🇺 Russia"
echo country_flag_emoji('RU', null, ' '), 'Russia', PHP_EOL;
// or
echo country_flag_emoji('RU', '', ' '), 'Russia', PHP_EOL;
// ISO Code: "RU"
// Extension Left: " "
// Extension Right: " "
// Output: " 🇷🇺 Russia"
echo country_flag_emoji('RU', ' ', ' '), 'Russia', PHP_EOL;