PHP code example of mtownsend / read-time

1. Go to this page and download the library: Download mtownsend/read-time library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mtownsend / read-time example snippets


/*
 * Package Service Providers...
 */
Mtownsend\ReadTime\Providers\ReadTimeServiceProvider::class,

$app->register(Mtownsend\ReadTime\Providers\ReadTimeServiceProvider::class);

return [

    /*
     * Whether or not minute/second should be abbreviated as min/sec
     */
    'abbreviate_time_measurements' => false,

    /*
     * Omit seconds from being displayed in the read time estimate
     */
    'omit_seconds' => true,

    /*
     * Whether or not only the time should be displayed
     */
    'time_only' => false,

    /*
     * The average words per minute reading time
     */
    'words_per_minute' => 230,
];

use Mtownsend\ReadTime\ReadTime;

$readTime = (new ReadTime($content))->get();

use Mtownsend\ReadTime\ReadTime;

$readTime = (new ReadTime($content, $omitSeconds = true, $abbreviated = false, $wordsPerMinute = 230))->get();
// or
$readTime = (new ReadTime($content))
				->omitSeconds()
				->abbreviated()
				->wpm($wordsPerMinute)
				->get();

use Mtownsend\ReadTime\ReadTime;

$readTime = (new ReadTime([$content, $moreContent, $evenMoreContent]))->get();

[
    'reads_left_to_right' => true,
    'min' => 'min',
    'minute' => 'minute',
    'sec' => 'sec',
    'second' => 'second',
    'read' => 'read'
]

read_time($content);
`
php artisan vendor:publish --provider="Mtownsend\ReadTime\Providers\ReadTimeServiceProvider" --tag="read-time-language-files"
`
<h1>Some blog title</h1>
<small>{{ read_time($content) }}</small>
<hr>
`
<h1>Some blog title</h1>
<small>{{ read_time([$content, $moreContent]) }}</small>
<hr>
`
{{ read_time([
    'content' => $content,
    // or
    // 'content' => [$content, $moreContent],
    'omit_seconds' => true,
    'time_only' => false,
    'abbreviated' => true,
    'words_per_minute' => 230,
    'ltr' => true,
    'translation' => [
        'reads_left_to_right' => true,
        'min' => 'min',
        'minute' => 'minute',
        'sec' => 'sec',
        'second' => 'second',
        'read' => 'read'
    ]
]) }}