Skip to content

Instantly share code, notes, and snippets.

@davidsword
Created September 14, 2016 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsword/657de8877eb3bff3f5fc31e2a439c134 to your computer and use it in GitHub Desktop.
Save davidsword/657de8877eb3bff3f5fc31e2a439c134 to your computer and use it in GitHub Desktop.
<?
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