php 过滤emoji表情
function yz_expression()
{
foreach ($_POST as $key => &$value) {
$value = preg_replace_callback('/[\xf0-\xf7].{3}/', function($r) { return '@E' . base64_encode($r[0]);},$value); $countt=substr_count($value,"@");
for ($i=0; $i < $countt; $i++) {
$c = stripos($value,"@");
$value=substr($value,0,$c).substr($value,$c+10,strlen($value)-1);
}
$value = preg_replace_callback('/@E(.{6}==)/', function($r) {return base64_decode($r[1]);}, $value); }
return $_POST;
}
/**
* 替换掉数组中的emoji表情
* @param $arrayString
* @param string $replaceTo
* @return mixed|string
*/
public static function filterEmojiDeep($arrayString,$replaceTo = '?')
{
if(is_string($arrayString))
{
return self::filterEmoji($arrayString,$replaceTo);
}
else if(is_array($arrayString))
{
foreach($arrayString as &$array)
{
if(is_array($array) || is_string($array))
{
$array = self::filterEmojiDeep($array,$replaceTo);
}
else
{
$array = $array;
}
}
}
return $arrayString;
} /**
* 替换掉emoji表情
* @param $text
* @param string $replaceTo
* @return mixed|string
*/
public static function filterEmoji($text, $replaceTo = '?')
{
$clean_text = "";
// Match Emoticons
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
$clean_text = preg_replace($regexEmoticons, $replaceTo, $text);
// Match Miscellaneous Symbols and Pictographs
$regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
$clean_text = preg_replace($regexSymbols, $replaceTo, $clean_text);
// Match Transport And Map Symbols
$regexTransport = '/[\x{1F680}-\x{1F6FF}]/u';
$clean_text = preg_replace($regexTransport, $replaceTo, $clean_text);
// Match Miscellaneous Symbols
$regexMisc = '/[\x{2600}-\x{26FF}]/u';
$clean_text = preg_replace($regexMisc, $replaceTo, $clean_text);
// Match Dingbats
$regexDingbats = '/[\x{2700}-\x{27BF}]/u';
$clean_text = preg_replace($regexDingbats, $replaceTo, $clean_text);
return $clean_text;
}
php 过滤emoji表情的更多相关文章
- java代码过滤emoji表情
可以新建一个过滤器的类,在类中书写如下代码: public static String filterEmoji(String source) { if(source != null ...
- java过滤emoji表情(成功率高)
转载自:http://blog.csdn.net/huangchao064/article/details/53283738 基本能过滤大部分的ios,安卓,微信emoji表情 有很多别的帖子搜出来很 ...
- 过滤特殊字符(包括过滤emoji表情)
/** * 过滤特殊字符 * @param $text * @return mixed */ public static function filterSpecialChars($text) { // ...
- python3 清除过滤emoji表情
python3 清除过滤emoji表情 方法一: emoji处理库,emoji官网:https://pypi.org/project/emoji/ #安装 pip install emoji 官方例子 ...
- Js 过滤emoji表情...持续补充中..
原文来自: https://www.cnblogs.com/tsjTSJ/p/7065544.html 最全最详细的用JS过滤Emoji表情的输入 在前端页面开发过程中,总会碰到不允许输入框输入e ...
- 过滤emoji表情符
1.使用正则匹配 public function remove_emoji($text){ return preg_replace('/([0-9|#][\x{20E3}])|[\x{ ...
- 最全最详细的用JS过滤Emoji表情的输入
在前端页面开发过程中,总会碰到不允许输入框输入emoji表情的需求,我的思路是通过编码用正则匹配表情,然后将其替换为空字符创.但是问题也是显而易见的,完整的编码集是什么呢?查阅了官方文档,发现上面并没 ...
- 用JS过滤Emoji表情的输入
本文为原创,转载请注明出处: cnzt 文章:cnzt-p http://www.cnblogs.com/zt-blog/p/6773854.html 在前端页面开发过程中,总会碰到不允许 ...
- java过滤emoji表情
import java.util.regex.Matcher; import java.util.regex.Pattern; public class test { /** * 表情过滤 * */ ...
随机推荐
- WinForm ListView
今天,我学习了公共控件中的ListView的内容. 首先,在利用ListView布置界面时,有以下三个方面: 1.视图: 在其右上方小箭头点击将视图改为Details:或者右键属 ...
- SVN解锁失败的解决办法
背景:在版本发布后,本人把工程文件上锁后,进行过修改但没有进行上传.后面一段时间后,开发人员需要进行修改提交,发现解锁不成功. 使用解锁命令时:提示如下: If you want to break t ...
- Output\TEST.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST.
点击错误信息,跳转到了一个.sct文件:*.o (RESET, +First) 按照如下操作,也不能解决问题.对比别的工程,也没找出问题. "操作是: Options for Target ...
- Documention
Object.bool Does the object exist? Object.name Components share the same name with the game object a ...
- selenium grid的使用与配置
一.selenium grid的组成与作用:由一个集线器hub和多个客户机node组成,如果你的程序需要在不用的浏览器,不同的操作系统上测试,而且比较多的case需要多线程远程执行,那么一个比较好的测 ...
- QT 报错:Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.
1.打开终端,输入指令并按回车键: sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer 2.如果电脑设置有密码,终 ...
- javascript windows对象
1.windows对象方法 2.计时器方法 3.计时器setInterval() <!DOCTYPE HTML> <html> <head> <meta ht ...
- XSL相关
<?xml version="1.0" encoding="utf-8" ?> <?xml-stylesheet type="tex ...
- Qt 5.7 > QML
本文档翻译自Qt官方文档: http://doc.qt.io/qt-5/qtqml-index.html Qt QML Qt QML模块使用QML语言为开发应用与库提供一个框架.它定义并实现了语言与引 ...
- Windows下怎么搭建Python+Selenium的自动化环境
http://jingyan.baidu.com/article/47a29f244aec6bc014239985.html 注意点:配置了环境变量后需要重启电脑