Home > Article > Backend Development > MySQL traverses the string and determines whether the string is all Chinese or contains Chinese implementation code in PHP
1. The judgment is all in Chinese
Copy the code The code is as follows:
$str="'324 is";
if(!eregi("[^x80-xff]","$str")) {
echo "all in Chinese";
}else{
echo "not";
}
Copy the code The code is as follows:
$str = "Chinese";
if (preg_match("/[x7f-xff]/", $str)) {
echo "Contains Chinese";
}else{
echo "No Chinese";
}
or
$pattern = '/[^ x00-x80]/';
if(preg_match($pattern,$str)){
echo "Contains Chinese";
}else{
echo "No Chinese";
}
The above introduces the implementation code of mySQL traversing strings in PHP to determine whether a string is all Chinese or contains Chinese characters, including the content of mySQL traversing strings. I hope it will be helpful to friends who are interested in PHP tutorials.