Go homepage(回首页) Upload pictures (上传图片) Write articles (发文字帖)
The author:(作者)归海一刀published in(发表于) 2014/2/10 6:49:03 PHP截取UTF-8字符串,解决半字符问题_[PHP教程]
function utf_substr(str,len){ for(i=0;i { temp_str=substr(str,0,1); if(ord(temp_str) > 127){ i++; if(i new_str[]=substr(str,0,3); str=substr(str,3); } } else { new_str[]=substr(str,0,1); str=substr(str,1); } } return join(new_str);}
赞