我們?cè)谕ㄟ^(guò)PHP獲取微信昵稱(chēng),并且存于數(shù)據(jù)庫(kù)的時(shí)候,由于一些昵稱(chēng)帶有特殊符號(hào),所以存不進(jìn)去,這時(shí)候我們可以通過(guò)下面的方式來(lái)處理。
方法二
protected 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","","這里是昵稱(chēng)")
方法三
// 過(guò)濾掉emoji表情 function filterEmoji($str){ $str = preg_replace_callback( '/./u', function (array $match) { return strlen($match[0]) >= 4 ? '' : $match[0]; }, $str); return $str; }
分享名稱(chēng):PHP方法處理微信昵稱(chēng)特殊符號(hào)過(guò)濾
文章分享:http://m.rwnh.cn/article42/cgcohc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、建站公司、服務(wù)器托管、外貿(mào)建站、網(wǎng)站內(nèi)鏈、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)