Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert emoji to html code or display emoji as html

Tags:

php

emoji

I want to covert emoji 😀 to html 😀 and display html code not emoji in my website, i use htmlentities("😀"); but not working at all. How to display emoji as html code in my website or convert it?

like image 911
Rio Susanto Avatar asked Feb 06 '23 19:02

Rio Susanto


1 Answers

$utf32  = mb_convert_encoding( "😀", 'UTF-32', 'UTF-8' );
$hex4 = bin2hex($utf32);
$dec = hexdec($hex4);
echo "&#$dec;";        // 😀
echo "&#$dec;";    // 😀
like image 162
Rick James Avatar answered Feb 10 '23 11:02

Rick James