復制代碼 代碼如下:
<?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 "<pre>";
echo "數字個數:".count($arrNum[0])."<br/>";
echo "字母個數:".count($arrAl[0])."<br/>";
echo "中文個數:".count($arrCh[0]);
?>