当前位置:网站首页>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);
边栏推荐
- 数据恢复软件EasyRecovery支持恢复所有类型的文件
- The server quit without updating PID file (/usr/local/mysql/data/localhost.pid).
- The 7 taboos of time management summarized by the postgraduate students, how many have you won?
- Go-12-Structure
- 项目经理VS产品经理,二者到底有何不同?
- 为什么应用程序依赖关系映射对于云迁移至关重要
- js实现数组去重的方式(7种)
- Go-11 - Process Control
- 边缘计算的三个关键好处
- Difference between KQL and Lucene
猜你喜欢
JDBC technology (3) - use Druid database connection pool test
HCIP-R&S By Wakin自用笔记(3)OSPF之各类LSA及LSA更新规则
33. 分别谈谈联合索引生效和失效的条件
数仓第一篇:基础架构
ROS2 ERROR: OpenGL 1.5 is not supported in GLRenderSystem::initialiseContext at C:\ci\ws\build...
解决有路由策略的情况下域内NAT不通的问题
PMP有什么答题技巧?
企业从云服务的承诺支出中获得最大收益的四种方法
数仓第二篇: 数据模型(维度建模)
如何在群晖系统中安装cpolar(群晖6.X版)
随机推荐
Z-Game on grid(牛客多校赛)
D. Tournament Countdown
显著性检验--学习笔记
composer的使用记录
Summary of pytorch related knowledge points
【Unity】判断鼠标是否点击在UI上
2020.10.13 Development log
The 7 taboos of time management summarized by the postgraduate students, how many have you won?
力扣刷题记录1.5-----367. 有效的完全平方数
RF调试过程中现象一
MT4 / MQL4 entry to the master of EA course lesson two - commonly used functions
力扣刷题记录2.1-----27. 移除元素
Likou Brush Question Record 8.1-----206. Reverse linked list
The first lesson of HNUMSC-C language
Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules
解决有路由策略的情况下域内NAT不通的问题
[ANT]apache ant 安装说明
2022 PMP Project Management Certification Exam Registration Guide (1)
OpenMLDB + Jupyter Notebook:快速搭建机器学习应用
Composer usage record