Posted in PHP onSeptember 22, 2013
<?php if(strlen($r[title])>45){$str=utf8Substr($r[title],0,15)."...";}else{$str=$r[title];}echo $str; ?> //截取utf8字符串 function utf8Substr($str, $from, $len) { return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'. '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s', '$1',$str); }
PHP截断标题且兼容utf8和gb2312编码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@