5月 4th, 2009

wordPress中实现中文截取的函数

Category: php, WordPress, Author: admin, Popularity: 25%

function utf8_trim($str) {

$len = strlen($str);

for ($i=strlen($str)-1; $i>=0; $i-=1){
$hex .= ‘ ‘.ord($str[$i]);
$ch = ord($str[$i]);
if (($ch & 128)==0) return(substr($str,0,$i));
if (($ch & 192)==192) return(substr($str,0,$i));
}
return($str.$hex);
}

function mul_excerpt ($excerpt,$excerpt_length) {
$myexcerpt = substr($excerpt,0,$excerpt_length);
return utf8_trim($myexcerpt) . ‘… ‘;
}

相关日志

Tags:.
评论数量() | Add Comments
本文网址:http://www.9usb.net/200905/wordpress-hanshu.html

There are No comments.

» You can leave a response

leave a reply