Last active
December 28, 2015 04:49
-
-
Save fahdi/7445520 to your computer and use it in GitHub Desktop.
Medium-like estimated reading time in PHP as on https://forrst.com/posts/Medium_like_estimated_reading_time_in_PHP-G6j
This file contains 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