// 中文字符串截取
function utf8_substr($str, $start, $length) {
$pa=”/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|”;
$pa.=”\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/”;
preg_match_all($pa, $str, $t_string);
if(count($t_string[0]) - $start > $length) {
return join(”, array_slice($t_string[0], $start, $length)) . “..”;
} else {
return join(”, array_slice($t_string[0], $start, $length));
}
}
PHPLAMP博客是专注于网站建设,搜索引擎研究,网站推广,网站优化的IT博客。