根据文章字数统计和预计阅读时间

      发布在:后端技术      评论:0 条评论
//字数和预计阅读时间统计函数
//根据正文内容计算出预计阅读时间
function count_words_read_time ($title,$content) {
global $post;
$text_num = mb_strlen(preg_replace('/\s/','',html_entity_decode(strip_tags($content))),'UTF-8');
//除以400,是基于百度的普通人的平均阅读速度(300~500)字/分钟
$read_time = ceil($text_num/400);
$output = '本文《' . $title .'》共' . $text_num . '个字,系统预计阅读时间或需' . $read_time . '分钟。';
return $output;
}


热门推荐