Calculate post read time using PHP Example

Today, We want to share with you Calculate post read time using PHP.In this post we will show you estimated reading time calculator, hear for wordpress reading time without plugin we will give you demo and example for implement.In this post, we will learn about how long does it take to read an article with an example.

Calculate post read time using PHP

There are the Following The simple About Calculate post read time using PHP Full Information With Example and source code.

As I will cover this Post with live Working example to develop article read time using PHP, so the some major estimated reading time php for this example is following below.

Read Also:  PHP Inline Editing Table using jQuery Ajax

Estimated reading time in PHP

According to the web page tech or any, the average each post reading speed is between about 230-280 words per minute.

<?php
function getReadTime($allcontent = ''){
    $total_word = str_word_count(strip_tags($allcontent));
    $m = floor($total_word / 230);
    $s = floor($total_word % 230 / (230 / 60));
    $estimateTime = $m . ' minute' . ($m == 1 ? '' : 's') . ', ' . $s . ' second' . ($s == 1 ? '' : 's');

    return $estimateTime;
}

Example 2: Add Estimated Reading Time In Your WordPress Posts

Add the reading time of WordPress Post
functions.php

if (!function_exists('yhello_get_reading_time')):
	function yhello_get_reading_time($text){

		//PHP Round fractions up so the sample text post minimum read time is 1 minute
		$totalReadTm = ceil(str_word_count($text)/200);
		if ($totalReadTm == 1){
			$totalReadTm = $totalReadTm . ' minute read';
		}else{
			$totalReadTm = $totalReadTm . ' minutes read';
		}
		return $totalReadTm;
	}
endif;

simple blog template

<div class="read-time">
      <?php echo yhello_get_reading_time(get_the_content()); ?>
</div>

Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  PHP Laravel Get Last Inserted ID in MySQL Table

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.


I hope you get an idea about Calculate post read time using PHP.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.