it fit chinese like language
when the $body content have both chinese and english
if( strlen($body) > 80 ) $body = substr($body,0,80).'...';
sometimes ,it will cut one chinese word to two part
eg:
$body="aaaaa中(it is a chinese word)";
$body = substr($body,0,6);
i use the the code to fit it
=================================
function ChgTitle($title,$length)
{
if (strlen($title)>$length) {
$temp = 0;
for($i=0; $i<$length; $i++) {
if (ord($title[$i]) > 128) {//whether or not a chinese word
$temp++;
}
}
if ($temp%2 == 0) {
$title = substr($title,0,$length)."...";
}else{
$title = substr($title,0,$length+1)."...";
}
}
return $title;
}
=================================
eg:
===============
$body=ChgTitle($body,80);