/*
Utf-8、gb2312都支援的漢字截取函數
cut_str(字串, 截取長度, 開始長度, 編碼);
編碼預設為utf-8
開始長度預設為0/
*
function cut_str($string, $sublen, $start = 0, $code = 'UTF-8')
{
if($code == 'UTF-8')
if($code == 'UTF-8')
/[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 if( count($t_string[0]) - $start > $sublen) return join('', array_slice($t_string[0], $start, $sublen))."...";
array_slice($t_string[0], $start, $sublen));
}
else
$sublen = $sublen*2;
$strlen = strlen($string);
$tmpstr = '';
for($i=0; $i=$start && $i {
if(ord(substr($string, $i, 1))>129)
{ $i, 2);
}
{
$tmpstr.= substr($ string, $i, 1);
}
$i, 1))>129) $i++;
}
if(strlen($tmpstr) return $tmpstr;
}
}
$str = 「
?>
//移除中文字串
//支援GB2312
function mysubstr($ $strlen = $start + $len;
for($i = 0; $i if(ord(substr($str, $i, 1)) > 0xa0 ($str, $i, 2);
$i++;
.= substr($str, $i, 1);
}
return $tmp ?>
//截取utf8字串
function utf8Substr($str, $from, $len)
{T xFF][x80-xBF]+){0,'.$from.'}'.
$len.'}).*#s',
);