php教程|php手册
php,中,支持,多种,编码,中文,字符串,截取,函数,支持,多种,编码,中文,字符串,截取,函数,复制,代码,
php教程-php手册
支持多种编码的中文字符串截取函数!
仿答题pk源码,ubuntu怎么换成英文,TOMCAT9内存占用高,ip 地址库 爬虫,疫情过后php工作好找吗,软件seo 营销lzw
复制代码 代码如下:
dj舞曲音乐系统源码,ubuntu打不出冒号,天津爬虫ip厂,报销 php 源码,大国匠心seolzw
/*
* @todo 中文截取,支持gb2312,gbk,utf-8,big5
*
* @param string $str 要截取的字串
* @param int $start 截取起始位置
* @param int $length 截取长度
* @param string $charset utf-8|gb2312|gbk|big5 编码
* @param $suffix 是否加尾缀
*/
织梦模板源码免费下载,vscode uniapp插件,ubuntu远程桌面花屏,the tomcat,sqlite求差集,服务器含义,京东商城插件,前端框架怎么找,网络爬虫使用教程,php 打印,合肥网站优化seo,快法务网站源码,网页打赏代码,仿新闻网站wap模板,html动态页面模板下载,超市管理系统源代码 c,cps广告联盟程序lzw
function csubstr($str, $start=0, $length, $charset=”utf-8″, $suffix=true)
{
if(function_exists(“mb_substr”))
return mb_substr($str, $start, $length, $charset);
$re[‘utf-8’] = “/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/”;
$re[‘gb2312’] = “/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/”;
$re[‘gbk’] = “/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/”;
$re[‘big5’] = “/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/”;
preg_match_all($re[$charset], $str, $match);
$slice = join(“”,array_slice($match[0], $start, $length));
if($suffix) return $slice.”…”;
return $slice;
}