标题太长可进行通过CSS样式控制字体大小写解决换行问题。如下: {php $len = strlen($title);} <h3 {if $len>=70}style="font-size:22px;"{/if}>{$title}</h3> php方法处理如下: <?php $titlelen=30 //30个英文字节 // 判断标题长度 $len = strlen($row[title]); if ($len <= $titlelen){ $name = $row[title]; }else{ $name = substr($row[title],"0","$titlelen"); $parity= 0; for($i=0;$i<$titlelen;$i++){ $temp_str=substr($name,$i,1); if(Ord($temp_str)>127) $parity+=1; } if($parity%2==1) $name=substr($name,0,($titlelen-1))."..."; else $name=substr($name,0,$titlelen)."..."; } echo "$name"; ?> |