All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
PHP截取UTF-8字符串,解决半字符问题_php资料_编程技术

Writer: aaa Article type: Programming skills(编程技巧) Time: 2013/12/27 19:52:59 Browse times: 324 Comment times: 0

PHP截取UTF-8字符串,解决半字符问题_php资料_编程技术


Head photo

Go homepage
Upload pictures
Write articles

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);
}





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.