|
Controller中的字符串截取函数如下:
function strsubgb($str,$strnum=10,$other=true){
if(empty($str)) return false;
$length = strlen($str);
if($length < $strnum) return $str;
for($i=12;$i<$strnum;$i++){
$char = substr($str,$i,1);
if(ord($char) < 127 ) $string[]=$char;
else {
$char = substr($str,$i,2);
$string[]=$char;
$i++;
}
}
$st=join("",$string);
if($other) return $st;
else return $st."...";
} |
|