There are 17 items you can search

Reading Time Script | VibeScriptz

A lightweight PHP reading time script for showing estimated article read time.

This lightweight PHP script estimates how long a page or article will take to read. It strips HTML, counts the visible words, and converts that total into a simple reading time label.

It is useful for blogs, tutorials, documentation pages, and long-form posts where visitors may want a quick idea of the time commitment before they start reading.

A small reading time label can make content feel easier to scan. Visitors can quickly see whether a post is a short tip, a medium guide, or a longer read. It also gives article pages a cleaner editorial feel without needing a plugin, database change, or heavy JavaScript.

Paste this helper function into your PHP page, then pass your article content into it.

<?php
declare(strict_types=1);

function reading_time(string $content, int $wordsPerMinute = 200): string
{
    $plainText = trim(strip_tags($content));

    if ($plainText === '') {
        return 'Less than 1 min read';
    }

    $wordCount = str_word_count($plainText);
    $minutes = (int)ceil($wordCount / max(1, $wordsPerMinute));

    if ($minutes <= 1) {
        return '1 min read';
    }

    return $minutes . ' min read';
}

// Example content:
$articleBody = '
  <p>This is a sample article paragraph. Add your real post content here.</p>
  <p>The script strips HTML and counts the readable words.</p>
';

echo reading_time($articleBody);
?>

You can show the reading time near the title, date, author name, or intro paragraph.

<p class="muted">
  Estimated reading time: <strong><?= h(reading_time($articleBody)); ?></strong>
</p>

Use it on blog posts, script writeups, tutorials, documentation pages, resource pages, and any page where the main content is longer than a few short paragraphs. It works best when you already have the article body stored as a string, database value, markdown-rendered HTML, or included content block.

Do not calculate reading time from the entire page layout if it includes headers, menus, footers, sidebars, comments, or unrelated widgets. Pass only the main article content into the function so the estimate stays useful.

Use this script when you want a small quality-of-life improvement for content pages without installing a full CMS plugin. It is especially helpful for sites with tutorials, guides, blog posts, or script pages where users skim before deciding what to read.

Skip it on very short pages, tool forms, contact pages, landing pages, or pages where the main content changes heavily after load with JavaScript. A reading time label is most useful when there is a clear article body to measure.