Lukin
新手上路

UID 91227
精华
0
积分 38
帖子 18
金钱 38 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2007-4-13 来自 上海
状态 离线
|
[推荐阅读] 怎么用类把数据库内容读取出来
英文可以 中文不可以
把strlen换成mb_strlen
把substr 换成mb_substr试试
先查查手册 mb_strlen 和 mb_substr 怎么用再写!~
如果不行的话 你在用第二招
把strlen和substr换成下面这两个函数吧
<?php //支持中文的substr(string,length[,start]) function cnsubstr($l1,$l2,$l3=0){ $I2 = "/[x01-x7f]|[xc2-xdf][x80-xbf]|xe0[xa0-xbf][x80-xbf]|[xe1-xef][x80-xbf][x80-xbf]|xf0[x90-xbf][x80-xbf][x80-xbf]|[xf1-xf7][x80-xbf][x80-xbf][x80-xbf]/"; preg_match_all($I2,$l1,$I3); if (count($I3[0]) - $l3 > $l2) { return implode('',array_slice($I3[0],$l3,$l2))."..."; } return implode('',array_slice($I3[0],$l3,$l2)); } //计算中文字符长度 function len($l1){ $I2 = "/[x01-x7f]|[xc2-xdf][x80-xbf]|xe0[xa0-xbf][x80-xbf]|[xe1-xef][x80-xbf][x80-xbf]|xf0[x90-xbf][x80-xbf][x80-xbf]|[xf1-xf7][x80-xbf][x80-xbf][x80-xbf]/"; preg_match_all($I2,$l1,$I3); return count($I3[0]); } ?> [ 本帖最后由 Lukin 于 2007-9-22 01:00 PM 编辑 ]
|  http://www.lukin.net |
|