Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)aaa
published in(发表于) 2013/12/27 19:52:59
PHP截取UTF-8字符串,解决半字符问题_php资料_编程技术

PHP截取UTF-8字符串,解决半字符问题_php资料_编程技术-你的首页-uuhomepage.com
function utf_substr($str,$len)
{
for($i=0;$i<$len;$i++)
{
$temp_str=substr($str,0,1);
if(ord($temp_str) > 127){
$i++;
if($i<$len) {
$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);
}





If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759