Last Updated: February 25, 2016
·
878
· iantearle

Estimated reading time

Estimate the reading time for blog posts. According to Wikipedia1 the average reading speed for an adult on paper is 200 and 180 on monitor. With the quality of monitors (screens) getting better with technology like Retina and high DPI display screens on most android devices I have simply used the 200 word per minute average.

<?php
$words = str_word_count(strip_tags($content));
$min = floor($words / 200);
$sec = floor($words % 200 / (200 / 60));
$est = $min . ' minute' . ($min == 1 ? '' : 's') . ', ' . $sec . ' second' . ($sec == 1 ? '' : 's');
?>

<p>Reading time: <?php echo $est; ?></p>

1 http://en.wikipedia.org/wiki/Words_per_minute#Reading_and_comprehension

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside