php截取字符串,解决乱码问题与html标签问题

WBOY
Release: 2016-06-23 13:31:38
Original
1069 people have browsed it

public function  f截取字符串($str,$start,$len) {//$str是指字符串,$start指字符串的起始位置,$len指字符串长度    $len=$len*3;    $strlen=$start+$len; //用$strlen存储字符串的总长度    $tmpstr='';    for($i=0;$i0xa0) { //如果字符串中出现汉字,也就是ASC码大于0xa0的。作出判断与英文字符不一样。            $tmpstr.=mb_substr($str,$i,2,'utf-8');            //$tmpstr.=substr($str,$i,2);            $i++;        }        else            $tmpstr.=mb_substr($str,$i,1,'utf-8');    }    return $tmpstr;}
Copy after login

版权声明:本文为博主原创文章,未经博主允许不得转载。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!