当前位置:网站首页>php过滤特殊字符(仅保留中文、字母、数字、下划线)
php过滤特殊字符(仅保留中文、字母、数字、下划线)
2022-08-09 02:21:00 【yutiedun】
php过滤特殊字符,仅保留中文、字母、数字、下划线
函数定义:
function match_chinese($chars,$encoding='utf8')
{
$pattern = ($encoding=='utf8')?'/[\x{4e00}-\x{9fa5}a-zA-Z0-9_]/u':'/[\x80-\xFF]/';
preg_match_all($pattern,$chars,$result);
$temp = join('',$result[0]);
return $temp;
}
使用方法:
$nickname = match_chinese($nickname);
边栏推荐
- The last exam before the NPDP revision!caution
- Phenomenon 1 during RF debugging
- JDBC技术(一)——一个简单的JDBC测试
- 史上最猛“员工”,疯狂吐槽亿万富翁老板小扎:那么有钱,还总穿着同样的衣服!
- .reduce()的简单例子
- 如何在群晖系统中安装cpolar(群晖6.X版)
- SEMRush如何寻找关键词用于投放广告
- 边缘计算的三个关键好处
- 2.1-----27. Remove elements
- New Swagger3.0 tutorial, OAS3 quick configuration guide, to automate API interface documentation!
猜你喜欢

数据库设计的总结

力扣刷题记录3.1-----977. 有序数组的平方

eladmin container deployment super detailed process

Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules

How SEMRush finds keywords for advertising

【云计算】XaaS最全介绍(按24字母合集):AaaS、BaaS、CaaS、DaaS、EaaS、FaaS、GaaS、HaaS、IDaaS…
![[C language brush questions] Application of fast and slow pointers in linked lists](/img/de/907192f705d9b2dc1628d480c4d7d9.png)
[C language brush questions] Application of fast and slow pointers in linked lists

Line segment tree of knowledge

Summary of Database Design

数字孪生+燃气管理,开启智慧燃气管理新模式
随机推荐
Mysql 5.7 into the pit
yii2的安装之路
中国SSD产业突围有多难?除了技术“瓶颈”还有哪里挑战?
The 7 taboos of time management summarized by the postgraduate students, how many have you won?
Which is the best increased whole life insurance?Is it really safe?
右键新建缺少word、excel选项问题处理
2022 PMP Project Management Certification Exam Registration Guide (1)
MT4/MQL4入门到精通EA课程第二课-常用的功能函数
2020.10.13 Development log
ROS 、SLAM 学习 error整理
Etcd realize large-scale application service management of actual combat
Go-12-Structure
2022 Eye Care Products Exhibition, Beijing Eye Health Exhibition, Ophthalmology Exhibition, Myopia Correction Equipment Exhibition
mysql连接超过八小时报错
10.1-----19. Delete the Nth node from the bottom of the linked list
2022眼康品牌加盟展,北京视力保健展,中国眼科医学技术峰会
物联网未来:未来五年的预期
软件开发之我的一点想法
JDBC技术(一)——一个简单的JDBC测试
eladmin容器部署超详细过程