Skip to content

Instantly share code, notes, and snippets.

@fahdi
Last active December 28, 2015 04:49
Show Gist options
  • Save fahdi/7445520 to your computer and use it in GitHub Desktop.
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
<?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