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