输入banner图图片脚本导航/分类

取得中文字符长度的小函数

  1. //中文字符长度,一个中文长度为1。

  2. function cstrlen($str){
  3. $n = 0; $p = 0; $c = ”;
  4. $len = strlen($str);

  5. for($i = 0; $i < $len; $i++) {

  6. $c = ord($str{$i});
  7. if($c > 127) {
  8. $p = 1;
  9. } else {
  10. $p = 0;
  11. }
  12. $i+=$p;$n++;
  13. }

  14. return $n;

  15. }
  16. ?>