Home > OS >  PHP convert emojis in string to unicode
PHP convert emojis in string to unicode

Time:03-26

I use the below code to convert an emoji to unicode, but how do i apply this to a string without affecting the other text in string.

function emoji_to_unicode($emoji) {
   $emoji = mb_convert_encoding($emoji, 'UTF-32', 'UTF-8');
   $unicode = strtoupper(preg_replace("/^[0] /","U ",bin2hex($emoji)));
   return $unicode;
}

$var = "           
  •  Tags:  
  • php
  • Related