Removing emojis from variable

后端 未结 3 1207
天命终不由人
天命终不由人 2021-02-04 20:36

I\'m using Smarty to pass in and display the contents of a first_name variable. Some users have Emoji characters (http://en.wikipedia.org/wiki/Emoji) in their

3条回答
  •  梦毁少年i
    2021-02-04 21:20

    The emoji are encoded in the block U+1F300–U+1F5FF.

    preg_replace('/\xEE[\x80-\xBF][\x80-\xBF]|\xEF[\x81-\x83][\x80-\xBF]/', '', $first_name)
    

    this will strip those out

提交回复
热议问题