中文截取函数
来源:互联网 发布:广发淘宝卡金卡和普卡 编辑:程序博客网 时间:2024/05/16 17:12
/*** 中文截取函数*/function mbsubstr($str, $start=0, $length, $suffix=true, $charset="utf-8") {if(function_exists("mb_substr"))$slice = mb_substr($str, $start, $length, $charset);elseif(function_exists('iconv_substr')) {$slice = iconv_substr($str,$start,$length,$charset);}else{$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(strlen($str) > strlen($slice)){return $suffix ? $slice.'...' : $slice;}else{return $slice;}}
0 0
- php截取中文函数
- 中文字符串截取函数
- php截取中文函数
- 中文截取函数
- PHP中文字符串截取函数
- 截取中文部分字符串函数
- C#中文字符截取函数
- mb_substr函数截取中文字符
- PHP中文字符串截取函数
- PHP截取中文字符串函数
- php 中文字符串截取函数
- PHP 截取中文字符函数
- 高效的中文字符串截取函数
- 高效的中文字符串截取函数(徐祖宁)
- 高效的中文字符串截取函数
- 高效的中文字符串截取函数
- 高效的中文字符串截取函数
- 中文字符串截取函数 substr_for_gb2312 and substr_for_utf8
- centos系统安装nod32杀毒软件并通过xmanager进行远程管理
- 从简单Sql探索优化之道
- PHP数据类型转换与常量的使用
- vs无法生成exe文件
- POJ3617 字典序最小问题
- 中文截取函数
- flume学习
- Android TextView自定义实现@用户跳转
- VBA,iLogic,插件中使用学徒服务器
- 进程与线程的区别与联系(经典面试题)
- Unity PoolManager
- 过拟合与欠拟合问题
- 博客地址更换
- build a devstack in a VM