$wordsPerMinute = 200; // Set Average Word Per Minute
$word = "This is an example of a very long text!";
$textLength = explode(" ", $word); // Split word by spaces(this will return an array)
$textLength = sizeof($textLength); // Get the size of the returned array
$result = $textLength / $wordsPerMinute;
$result = ceil($result); // Convert result to integer -- If a double value like 2.7 is returened, it will convert it to 3
echo $result."min";
Last active
September 26, 2020 23:42
-
-
Save AsaoluElijah/cfc1c70c3e86e83871c61c1f6e40f232 to your computer and use it in GitHub Desktop.
Calculate Reading Time With PHP - Asaolu Elijah
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment