sugar1569 7 лет назад
Родитель
Сommit
ef1089196c
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      application/common.php

+ 12 - 0
application/common.php

@@ -57,4 +57,16 @@ function makePathToUrl($path,$type = 2)
         return trim(str_replace(DS, '/',UPLOAD_PATH.$path),'.');
     }else return '';
 
+}
+// 过滤掉emoji表情
+function filterEmoji($str)
+{
+    $str = preg_replace_callback(    //执行一个正则表达式搜索并且使用一个回调进行替换
+        '/./u',
+        function (array $match) {
+            return strlen($match[0]) >= 4 ? '' : $match[0];
+        },
+        $str);
+
+    return $str;
 }