Last active
December 25, 2015 01:59
-
-
Save bondarewicz/6899641 to your computer and use it in GitHub Desktop.
PHP: Estimated reading time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function read_time($text){ | |
$words = str_word_count(strip_tags($text)); | |
$min = floor($words / 200); | |
if($min === 0) return '1 min read'; | |
return $min . 'min read'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment