/*
Chinese character interception function supported by Utf-8 and gb2312
cut_str(string, interception length, starting length, encoding);
The default encoding is utf-8
The default starting length is 0
* /
function cut_str($string, $sublen, $start = 0, $code = 'UTF-8')
{
if($code == 'UTF-8')
{
$pa = "/[ x01-x7f]|[xc2-xdf][x80-xbf]|xe0[xa0-xbf][x80-xbf]|[xe1-xef][x80-xbf][x80-xbf]|xf0[x90-xbf] [x80-xbf][x80-xbf]|[xf1-xf7][x80-xbf][x80-xbf][x80-xbf]/”; (count($t_string[0]) - $start > $sublen) return join('', array_slice($t_string[0], $start, $sublen))."...";
return join(' ', array_slice($t_string[0], $start, $sublen));
}
else
{
$start = $start*2;
$sublen = $sublen*2;
$strlen = strlen($string ;
{
substr($string, $i, 1); If(strlen($tmpstr)< $strlen ) $tmpstr.= "...";
return $tmpstr; ; $start + $len;
for($i = 0; $i < $strlen; $i++) {
= substr($str, $i, 2); Return $tmpstr;
}
?> xC0-xFF][x80-xBF]+){0,'.$from.'}'.
'.$len.'}).*#s',