How to remove Chinese in php

藏色散人
Release: 2023-03-01 22:08:01
Original
3251 people have browsed it

php method to remove Chinese: First create a PHP sample file; then set the "utf-8" encoding; then use the regular method to replace Chinese characters with null characters; finally save and execute the file.

How to remove Chinese in php

PHP removes Chinese characters in a string

Delete Chinese characters in a string, as long as regular replacement Chinese characters can be empty characters:

<?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); ?>
Copy after login

For more related knowledge, please visit PHP Chinese website!

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template