Estimate Reading Time

PHP: Estimate Reading Time

This tutorial will show how to create a function to estimate time for reading some text on your web or application. Many websites have shown the estimated reading time for the users at the same time may be helpful for the users to know how long they need to finish the reading. 

This tutorial uses $mytext as the variable for the text as shown below:


    $words = str_word_count(strip_tags($mytext));
    $minutes = floor( $words / 120 );

    if (1 <= $minutes) {
    } else {

    echo $estimated_time;

The output will be 1 minute, 37 seconds. If use CakePHP, the $mytext should be something like:

$mytext = $user->note;

That all. Happy coding :)