Home >Backend Development >PHP Problem >How to remove Chinese characters in php

How to remove Chinese characters in php

藏色散人
藏色散人Original
2020-09-11 09:30:182316browse

php method to remove Chinese characters: first create a PHP sample file; then use the regular expression "preg_replace('/([\x80-\xff]*)/i','',$a); "Just replace the Chinese characters with empty characters.

How to remove Chinese characters in php

Recommended: "PHP Video Tutorial"

PHP removes Chinese characters from strings

As the title says, to delete the Chinese characters in a string, just replace the Chinese characters with empty characters using regular rules:

<?php
header(&#39;Content-type:text/html;charset=utf-8&#39;);
 
 
function p($arr){
echo "<pre class="brush:php;toolbar:false">";
print_r($arr);
echo "
"; } $a = "河蟹)(社会afeowa#$%^!@@#zf吃饭fawgwea汉堡包agho_iawghowi我日)"; $result = preg_replace('/([\x80-\xff]*)/i','',$a); p($result); ?>

The above is the detailed content of How to remove Chinese characters in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn