Guest User

Untitled

a guest
Oct 21st, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. ## Emojis to Words
  2.  
  3. 1. json encode an emoji to get its surrogate pair
  4.  
  5. ```
  6. $surrogate_pair = json_encode(🌊);
  7. print $surrogate_pair; //"\ud83c\udf0a"
  8. ```
  9. 2. The surrogate pair is the key in the array, check if the key exists and send back the associated keyword. The `$emojis_to_words` variable is an array you need to include in your project.
  10. ```
  11. if(array_key_exists($surrogate_pair, $emojis_to_words)) {
  12. $keyword = $emojis[$surrogate_pair];
  13. print $keyword;
  14. }
  15. ```
  16. 3. In this example `print $keyword` will show you "waves".
Add Comment
Please, Sign In to add comment