Skip to content

Instantly share code, notes, and snippets.

@sursir
Created December 29, 2018 07:54
Show Gist options
  • Select an option

  • Save sursir/7c2e5f23e7cbe1fc1929de0a3894b6ab to your computer and use it in GitHub Desktop.

Select an option

Save sursir/7c2e5f23e7cbe1fc1929de0a3894b6ab to your computer and use it in GitHub Desktop.
php emoji unicode multi-byte
<?php
function removeEmoji($text)
{
$cleanText = "";
// Enclosed characters 24C2 - 1F251
$regexEnclosed = '/[\x{24C2}-\x{1F251}]/u';
$cleanText = preg_replace($regexEnclosed, '', $text);
// Dingbats 2702 - 27B0
$regexDingbats = '/[\x{2702}-\x{27B0}]/u';
$cleanText = preg_replace($regexDingbats, '', $cleanText);
// Match Miscellaneous Symbols and Pictographs
$regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
$cleanText = preg_replace($regexSymbols, '', $cleanText);
// Match Emoticons
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
$cleanText = preg_replace($regexEmoticons, '', $cleanText);
// Match Transport And Map Symbols
$regexTransport = '/[\x{1F680}-\x{1F6FF}]/u';
$cleanText = preg_replace($regexTransport, '', $cleanText);
return $cleanText;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment