[转载 php]php截取utf8编码的中文函数

< ?php
//截取utf8字符串
function utf8Substr($str, $from, $len) {
     return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
                       '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
                       '$1',$str);
}
?>
posted on 2008-06-19 17:35  真阿当  阅读(85)  评论(0编辑  收藏  举报