Created
March 24, 2020 04:46
-
-
Save julkwel/4f201468946ea39a383dfdc38284d6be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Julien Rajerison <[email protected]> | |
**/ | |
/** | |
* Class HtmlToEmoji. | |
* | |
* Convert pattern to emoji | |
*/ | |
class HtmlToEmoji | |
{ | |
/** | |
* $string : string with text to convert | |
* | |
* @param string $string | |
* | |
* @return string|string[] | |
*/ | |
public static function convertTextToEmoji(string $string) | |
{ | |
$emojis = [ | |
"o/" => "π", | |
"</3" => "π", | |
"<3" => "π", | |
"8-D" => "π", | |
"8D" => "π", | |
":-D" => "π", | |
":-3" => "π", | |
":3" => "π", | |
":D" => "π", | |
"B^D" => "π", | |
"X-D" => "π", | |
"XD" => "π", | |
"x-D" => "π", | |
"xD" => "π", | |
":\")" => "π", | |
":\"-)" => "π", | |
":-))" => "π", | |
"8)" => "π", | |
":)" => "π", | |
":-)" => "π", | |
":]" => "π", | |
":^)" => "π", | |
":c)" => "π", | |
":o)" => "π", | |
":}" => "π", | |
":γ£)" => "π", | |
"0:)" => "π", | |
"0:-)" => "π", | |
"0:-3" => "π", | |
"0:3" => "π", | |
"0;^)" => "π", | |
"O:-)" => "π", | |
"3:)" => "π", | |
"3:-)" => "π", | |
"}:)" => "π", | |
"}:-)" => "π", | |
"*)" => "π", | |
"*-)" => "π", | |
":-," => "π", | |
";)" => "π", | |
";-)" => "π", | |
";-]" => "π", | |
";D" => "π", | |
";]" => "π", | |
";^)" => "π", | |
":-|" => "π", | |
":|" => "π", | |
":(" => "π", | |
":-(" => "π", | |
":-<" => "π", | |
":-[" => "π", | |
":-c" => "π", | |
":<" => "π", | |
":[" => "π", | |
":c" => "π", | |
":{" => "π", | |
":γ£C" => "π", | |
"%)" => "π", | |
"%-)" => "π", | |
":-P" => "π", | |
":-b" => "π", | |
":-p" => "π", | |
":-Γ" => "π", | |
":-ΓΎ" => "π", | |
":P" => "π", | |
":b" => "π", | |
":p" => "π", | |
":Γ" => "π", | |
":ΓΎ" => "π", | |
";(" => "π", | |
"X-P" => "π", | |
"XP" => "π", | |
"d:" => "π", | |
"x-p" => "π", | |
"xp" => "π", | |
":-||" => "π ", | |
":@" => "π ", | |
":-." => "π‘", | |
":-/" => "π‘", | |
":/" => "π‘", | |
":L" => "π‘", | |
":S" => "π‘", | |
":\\" => "π‘", | |
":\"(" => "π’", | |
":\"-(" => "π’", | |
"^5" => "π€", | |
"^<_<" => "π€", | |
"o/\\o" => "π€", | |
"|-O" => "π«", | |
"|;-)" => "π«", | |
":###.." => "π°", | |
":-###.." => "π°", | |
"D-\":" => "π±", | |
"D8" => "π±", | |
"D:" => "π±", | |
"D:<" => "π±", | |
"D;" => "π±", | |
"DX" => "π±", | |
"v.v" => "π±", | |
"8-0" => "π²", | |
":-O" => "π²", | |
":-o" => "π²", | |
":O" => "π²", | |
":o" => "π²", | |
"O-O" => "π²", | |
"O_O" => "π²", | |
"O_o" => "π²", | |
"o-o" => "π²", | |
"o_O" => "π²", | |
"o_o" => "π²", | |
":$" => "π³", | |
"#-)" => "π΅", | |
":#" => "πΆ", | |
":&" => "πΆ", | |
":-#" => "πΆ", | |
":-&" => "πΆ", | |
":-X" => "πΆ", | |
":X" => "πΆ", | |
":-J" => "πΌ", | |
":*" => "π½", | |
":^*" => "π½", | |
"ΰ² _ΰ² " => "π ", | |
"*\\0/*" => "π", | |
"\\o/" => "π", | |
":>" => "π", | |
">.<" => "π‘", | |
">:(" => "π ", | |
">:)" => "π", | |
">:-)" => "π", | |
">:/" => "π‘", | |
">:O" => "π²", | |
">:P" => "π", | |
">:[" => "π", | |
">:\\" => "π‘", | |
">;)" => "π", | |
">_>^" => "π€", | |
"^^" => "π", | |
":sweat" => "π ", | |
]; | |
foreach ($emojis as $key => $emoji) { | |
$string = str_replace($key, $emoji, $string); | |
} | |
return $string; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment