Create AWESOME code snippets and share them with the world in seconds!

X

Read Time Calculator For Laravel

Published on July 9, 2024 by

Read Time Calculator for Laravel

Read Time Calculation helper function

Let's look at an example: The following code is a simple helper function that can calculate the time (in seconds) it takes for a person to read a string passed as an argument:

function calculate_read_time(string $words): int
{
return (int) ceil(
(Str::wordCount($words) / 265) * 60
);
}
Dinesh Uprety

Senior Software Engineer • Writer @ Laranepal • PHP, Laravel, Livewire, TailwindCSS & VueJS • CEO @ Laranepal & Founder @ laracodesnap

Filed in:

Discussion

Login or register to comment or ask questions

No comments or questions yet...

SPONSORED
Codesnap

Codesnap

Create AWESOME code snippets and share them with the world in seconds!