##The operating environment of this article: windows10 system, php7, thinkpad t480 Computer. It must be a very simple thing for friends who have learned PHP to filter strings. We can complete the filtering through regular expressions or PHP's own functions. But for those who How can we filter out invisible special characters accurately? Let’s take a look at the specific implementation code:php method to filter out invisible special strings: [$content = '123456 1'; $len = strlen($content); $str = ""; for($i=0;$ i<$len;$i ){if((ord($co...].
$content = '123456 1'; $len = strlen($content); $str = ""; for($i=0;$i<$len;$i++){ if((ord($content[$i]) >= 0x30 && ord($content[$i]) <= 0x39) || $content[$i] == "." || $content[$i] == " " || $content[$i] == "\t" || $content[$i] == "\n"){ $str = $str.$content[$i]; } }
The above is the detailed content of How to filter out invisible special strings in php. For more information, please follow other related articles on the PHP Chinese website!