Home > php教程 > php手册 > 使用php统计字符串中中英文字符的个数

使用php统计字符串中中英文字符的个数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:29:48
Original
1273 people have browsed it

本篇文章是对使用php统计字符串中中英文字符的个数的方法进行了详细的分析介绍,需要的朋友参考下

复制代码 代码如下:


echo $str = "43fdf测试fdsfadaf43543543职工问防盗锁防盗锁5345gfdgd";
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 "

";<br>echo "数字个数:".count($arrNum[0])."<br>";<br>echo "字母个数:".count($arrAl[0])."<br>";<br>echo "中文个数:".count($arrCh[0]);<br>?><br>
,香港虚拟主机,香港服务器,香港服务器


Copy after login
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template