- $str='天Find我';
- function cut_str($str='',$offset,$length){
- $str=iconv("utf-8","gb2312",$str);
- $str_len=strlen($str);
- $arr=array();
- for($i=0;$i if(ord($str{$i})>0x80){
- $arr[]=$str{$i}.$str{$i+1};
- $i++;
- continue;
- }
- $arr[]=$str{$i};
- }
- return array_slice($arr,$offset,$length);
- }
- var_dump(cut_str($str,0,2));
复制代码
|