PHP
·
发表于 5年以前
·
阅读量:8296
function ChgTitle($title)
{
$length = 46;
if (strlen($title)>$length) {
$temp = 0;
for($i=0; $i<$length; $i++)
if (ord($title[$i]) > 128)
$temp++;
if ($temp%2 == 0)
$title = substr($title,0,$length)."...";
else
$title = substr($title,0,$length+1)."...";
}
return $title;
}
ÔÀi¾ÍÊǽضÏÒ»¸o×Ö*u£¬¿´¿´ÆaascIIÂeÊDz»ÊÇ´oÓÚ128£¬Èç¹uÊÇ£¬ËµÃ÷½Ø¶ÏµÄÊÇÒ»¸oÈ«½Çºº×Ö£¬ÄÇô¾ÍÍ˺oÒ»¸o½Ø¶Ï¡£ÓÃ$length¿ØÖƳ¤¶È
±¸×¢£ºÑ»ÅжÏ×Öu´®ÀiÃaeµÄ >128 µÄ×Öu¸oÊý£¬Èç¹u°e½Ç×ÖuΪżÊý£¬Ôo±iʾλÖøպÃΪÕu¸oºº×Ö£¬Èç¹uΪÆaeÊý£¬ÔoΪ°e¸oºº×Ö£¬ÐeҪȡÏÂÒ»¸o×Ö*u