Use php to count the number of Chinese and English characters in the string. Copy the code as follows :? Phpecho $ str43fdf test fdsfadaf43543543 employee asked anti-Leech 5345 gfdgd; preg_match_all ([0-9] {1}, $ str, $ arrNum); preg_match_all ([a-zA-Z] {
The code is as follows:
Echo $ str = "43fdf test fdsfadaf43543543 the employee asked about the anti-Leech 5345 gfdgd ";
Preg_match_all ("/[0-9] {1}/", $ str, $ arrNum );
Preg_match_all ("/[a-zA-Z] {1}/", $ str, $ arrAl );
Preg_match_all ("/([/x {4e00}-/x {9fa5}]) {1}/u", $ str, $ arrCh );
Echo"
";
Echo "number:". count ($ arrNum [0])."
";
Echo "letter count:". count ($ arrAl [0])."
";
Echo "number of Chinese characters:". count ($ arrCh [0]);
?>
The http://www.bkjia.com/PHPjc/327831.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327831.htmlTechArticle code is as follows :? Php echo $ str = "43fdf test fdsfadaf43543543 employee asked anti-Leech 5345 gfdgd"; preg_match_all ("/[0-9] {1}/", $ str, $ arrNum ); preg_match_all ("/[a-zA-Z] {...