-
-
Save lunaczp/1d9382cf462d3ca59568caeb228872e8 to your computer and use it in GitHub Desktop.
Check Emoji exist in string
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
| /** | |
| * Check emoji from string | |
| * | |
| * @return bool if existed emoji in string | |
| */ | |
| function checkEmoji($str) | |
| { | |
| $regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u'; | |
| preg_match($regexEmoticons, $str, $matches_emo); | |
| if (!empty($matches_emo[0])) { | |
| return false; | |
| } | |
| // Match Miscellaneous Symbols and Pictographs | |
| $regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u'; | |
| preg_match($regexSymbols, $str, $matches_sym); | |
| if (!empty($matches_sym[0])) { | |
| return false; | |
| } | |
| // Match Transport And Map Symbols | |
| $regexTransport = '/[\x{1F680}-\x{1F6FF}]/u'; | |
| preg_match($regexTransport, $str, $matches_trans); | |
| if (!empty($matches_trans[0])) { | |
| return false; | |
| } | |
| // Match Miscellaneous Symbols | |
| $regexMisc = '/[\x{2600}-\x{26FF}]/u'; | |
| preg_match($regexMisc, $str, $matches_misc); | |
| if (!empty($matches_misc[0])) { | |
| return false; | |
| } | |
| // Match Dingbats | |
| $regexDingbats = '/[\x{2700}-\x{27BF}]/u'; | |
| preg_match($regexDingbats, $str, $matches_bats); | |
| if (!empty($matches_bats[0])) { | |
| return false; | |
| } | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment