-
加入我们
-
VIP定制
-
求关注
Thank you for visiting
029-81773686
全网开发&整合营销服务商
CopyRight
©HOOBOO All rights reserved
2020.07.22
宏博网络(西安高端网站建设公司)在通过PHP获取微信昵称,并且存于数据库的时候,由于一些昵称带有特殊符号,所以存不进去,这时候小博教你通过下面的方式来处理。
// 方法二
function removeEmoji($clean_text) {
// Match Emoticons
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
$clean_text = preg_replace($regexEmoticons, '', $clean_text);
// 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;
}
// 方法二
preg_replace("/[\x{1F600}-\x{1F64F}\x{1F300}-\x{1F5FF}\x{1F680}-\x{1F6FF}\x{2600}-\x{26FF}\x{2700}-\x{27BF}]/u","","这里是昵称")
// 过滤掉emoji表情
function filterEmoji($str){
$str = preg_replace_callback( '/./u', function (array $match) {
return strlen($match[0]) >= 4 ? '' : $match[0];
}, $str);
return $str;
}
CopyRight © 西安宏博网络科技有限公司 备案号:陕ICP备10007014号-8 站点地图 免责声明:本网站部分资源来源于网络,如有侵权,请联系我们告知删除,我们将会尽快处理,谢谢!本站不承担任何法律责任。