我需要用php計算所有德文字符的字符串。需要計算一個字符串中的德國字符php
我tryed這樣的:
$pattern = '/[äüöÄÜÖß]/';
$address = "Knnöstraße";
$counting = 0;
if(preg_match($pattern, $address)) {
$counting ++;
}
echo $counting;
但它返回我只是1.持何來算特殊字符的最佳方式?
隨着preg_all_match功能還給了我4,但它必須是2:
preg_match_all($pattern, $address, $matches, PREG_SET_ORDER);
echo count($matches);
http://php.net/manual/en/function.preg-match-all.php – AbraCadaver
它返回我4,但它必須是2 ... –