Can somebody tell me what it’s wrong on this line of code?
preg_match(/[\\x{4e00}-\\x{9fa5}]+.*\\-/u, $str, $matches);
Can somebody tell me what it’s wrong on this line of code?
preg_match(/[\\x{4e00}-\\x{9fa5}]+.*\\-/u, $str, $matches);
No quotes around your expression?
preg_match([B][COLOR=#ff0000]'[/COLOR][/B]/[\\x{4e00}-\\x{9fa5}]+.*\\-/u[COLOR=#ff0000][B]'[/B][/COLOR], $str, $matches);
Ok guys, in this case…
$url='https://mobile.twitter.com/zerotosi';
$data=file_get_contents($url);
preg_match('/[\\x{4e00}-\\x{9fa5}]+.*\\-/u', $data, $matches);
echo count($matches);
It will only return count($matches) = if it the language it’s chiness/japaness,and 0 if the characters are latins. How can i get the number of chiness/japaness letters used in a string?
Are you looking for http://php.net/manual/en/function.strlen.php ?
Use [fphp]mb_split[/fphp], then loop through the array to check if that char is of the desired language. If so, increment a value.
Or, you could use the RegEx above to consider 1 char a match, then use count on matches.