Created
September 14, 2016 19:37
-
-
Save davidsword/657de8877eb3bff3f5fc31e2a439c134 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<? | |
require('emoji_unicode.php'); | |
$text = "hello :world_map: . it's :hammer: :stopwatch:."; | |
//alphanumeric, hyphens, plus-signs, and underscores string, wrapped in colons | |
preg_match_all("/:([a-zA-Z0-9'_+-]+):/", $text, $emojis); | |
foreach ($emojis[1] as $emojiname) | |
if (isset($emoji_unicode[$emojiname])) | |
$text = str_replace(":".$emojiname.":", "&#x".$emoji_unicode[$emojiname].";", $text); | |
else | |
$text = str_replace(":".$emojiname.":", "(".$emojiname.")", $text); | |
echo $text; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment