-
加入我們
-
VIP定制
-
求關(guān)注
Thank you for visiting
029-81773686
全網(wǎng)開發(fā)&整合營銷服務(wù)商
CopyRight
?HOOBOO All rights reserved
2020.07.22
宏博網(wǎng)絡(luò)(西安高端網(wǎng)站建設(shè)公司)在通過PHP獲取微信昵稱,并且存于數(shù)據(jù)庫的時候,由于一些昵稱帶有特殊符號,所以存不進去,這時候小博教你通過下面的方式來處理。
// 方法二
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 ? 西安宏博網(wǎng)絡(luò)科技有限公司 備案號:陜ICP備10007014號-8 站點地圖 免責聲明:本網(wǎng)站部分資源來源于網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系我們告知刪除,我們將會盡快處理,謝謝!本站不承擔任何法律責任。