//中文字符长度,一个中文长度为1。function cstrlen($str){$n = 0; $p = 0; $c = ”;$len = strlen($str); for($i = 0; $i < $len; $i++) {$c = ord($str{$i});if($c > 127) { $p = 1; } else { $p = 0; } $i+=$p;$n++; } return $n; } ?> 复制代码