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.

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 :

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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Laravel 5.8 get current url with parameters
  2.   PHP Laravel 5.8 Image Uploading Tutorial
  3.   Simple VueJS Responsive Image Carousel Slider
  4.   Basic OOP PHP CRUD Operation Using MySQLi from Scratch
  5.   PHP Object Cloning Magic Methods Example
  6.   Laravel Soft Delete Unique validations
  7.   JSON Filter using Angular Example
  8.   Laravel Soft Delete Example Tutorial From Scratch
  9.   PHP artisan dump-autoload Fix "class not found"
  10.   Nodejs Real time online users counter using socket io Example