/* * emoji编码函数 * @author E */function user_text_encode($str){ if(!is_string($str))return $str; if(!$str || $str=='undefined')return ''; $text = json_encode($str); //暴露出unicode $text = preg_replace_callback("/(\\\u[ed][0-9a-f]{3})/i",function($str){ return addslashes($str[0]); },$text); //将emoji的unicode留下,这里的正则比原来增加了d,很多emoji实际上是\ud开头的,反而没发现有\ue开头。 return json_decode($text);}/* * emoji解码函数 * @author E */function user_text_decode($str){ $text = json_encode($str); //暴露出unicode $text = preg_replace_callback('/\\\\\\\\/i', function ($str) { return '\\'; }, $text); //将两条斜杠变成一条 return json_decode($text);}/* * emoji过滤函数 * @author E */function filter_emoji($data){ if(is_array($data) && !empty($data)){ foreach ($data as $k=>$v){ if(is_array($v) && !empty($v)){ $data[$k] = filter_emoji($v); }else{ $v = json_encode($v); $data[$k] = json_decode(preg_replace("/(\\\u[ed][0-9a-f]{3})/i","",$v)); } } } return $data;}


广告

给大家推荐几个好用的工具

时间校验工具ip查询工具二维码生成工具json格式化工具时间缀-时间转换工具