$country_code = 'US'; // Uppercase echo mb_convert_encoding( '&#' . ( 127397 + ord( $country_code ) ) . ';', 'UTF-8', 'HTML-ENTITIES'); echo mb_convert_encoding( '&#' . ( 127397 + ord( $country_code ) ) . ';', 'UTF-8', 'HTML-ENTITIES');
U this prints out 🇺 and for
S it prints out 🇸. When those two characters are side by side they get displayed as 🇺🇸.
If you have an improvement or this helps you out, leave a comment.