PHP 修复损坏的字符,如示例中所示

问题描述 投票:0回答:1

过滤这样的字符的最佳方法是什么:

็็็็็็็็็็็็็็็็็็็็็็็็็็็

在不破坏其他外来字符的情况下输出?

谢谢。

php regex replace unicode sanitization
1个回答
0
投票

如果您过滤正确的 Unicode 范围,这应该有效:

$str = 'Your string with Unicode symbols'
preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $str);

https://3v4l.org/EY06F

http://php.net/manual/en/function.preg-replace.php

© www.soinside.com 2019 - 2024. All rights reserved.