Skip to content

Instantly share code, notes, and snippets.

@dhassanali
Created February 4, 2018 08:32
Show Gist options
  • Save dhassanali/3980537f03edc23d2568953e2e133078 to your computer and use it in GitHub Desktop.
Save dhassanali/3980537f03edc23d2568953e2e133078 to your computer and use it in GitHub Desktop.
Clean Emoji from String
function cleanEmoji($str) {
$clean_text = "";
// Match Emoticons
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
$clean_text = preg_replace($regexEmoticons, '', $str);
// Match Miscellaneous Symbols and Pictographs
$regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
$clean_text = preg_replace($regexSymbols, '', $clean_text);
// Match Transport And Map Symbols
$regexTransport = '/[\x{1F680}-\x{1F6FF}]/u';
$clean_text = preg_replace($regexTransport, '', $clean_text);
// Match Miscellaneous Symbols
$regexMisc = '/[\x{2600}-\x{26FF}]/u';
$clean_text = preg_replace($regexMisc, '', $clean_text);
// Match Dingbats
$regexDingbats = '/[\x{2700}-\x{27BF}]/u';
$clean_text = preg_replace($regexDingbats, '', $clean_text);
return $clean_text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment