文章内容字数据分析
编号增添到在当下游戏主题函数公式设计 functions.php 中。
// 字数统计 function zm_count_words ($text) { global $post; if ( '' == $text ) { $text = $post->post_content; if (mb_strlen($output, 'UTF-8') < mb_strlen($text, 'UTF-8')) $output .= '<span class="word-count">共' . mb_strlen(preg_replace('/\s/','',html_entity_decode(strip_tags($post->post_content))),'UTF-8') .'字</span>'; return $output; } }
文章标题阅读理解时间间隔
代碼增多到现如今主体数学函数范例 functions.php 中。
// 阅读时间 function zm_get_reading_time($content) { $zm_format = '<span class="reading-time">阅读时间%min%分%sec%秒</span>'; $zm_chars_per_minute = 300; // 估算1分种阅读字数 $zm_format = str_replace('%num%', $zm_chars_per_minute, $zm_format); $words = mb_strlen(preg_replace('/\s/','',html_entity_decode(strip_tags($content))),'UTF-8'); $minutes = floor($words / $zm_chars_per_minute); $seconds = floor($words % $zm_chars_per_minute / ($zm_chars_per_minute / 60)); return str_replace('%sec%', $seconds, str_replace('%min%', $minutes, $zm_format)); } function zm_reading_time() { echo zm_get_reading_time(get_the_content()); }
读取原创文章数字和读书的时间码
展现内容页数编码:
<?php echo zm_count_words($text); ?>
展现看书期限源代码:
<?php zm_reading_time(); ?>
将所述赋值编号加到某个内容正文模板下载的尽量的位置便可。
不超过行数核算和阅览时段段是不很透彻,特意是阅览时段段,也扯淡,缺省是按CCTV播音员语调定的。
写完这篇课文,出现网络上有更整洁的码怎么用,差别是上边的码怎么用精准度到秒,下列的码怎么用只计算到分。
// 阅读时间 function count_words_read_time () { global $post; $text_num = mb_strlen(preg_replace('/\s/','',html_entity_decode(strip_tags($post->post_content))),'UTF-8'); $read_time = ceil($text_num/300); // 修改数字300调整时间 $output .= '本文共计' . $text_num . '个字,预计阅读时长' . $read_time . '分钟。'; return $output; }
都会进行代码怎么用:
<?php echo count_words_read_time(); ?>
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如果喜欢,请打赏支持本站,谢谢大家!
- 我的QQ
- QQ扫一扫
-
- 我的微信公众号
- 微信扫一扫
-
2020年4月10日 11:39 家里
2021年11月22日 10:50 板凳