Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$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);
$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
You can’t perform that action at this time.