/lib/Haanga/Extension/Filter/Truncatewords.php
http://github.com/crodas/Haanga · PHP · 13 lines · 12 code · 1 blank · 0 comment · 2 complexity · b726f084936531ccff773b4ef2963f2e MD5 · raw file
- <?php
- class Haanga_Extension_Filter_Truncatewords
- {
- static function main($text, $limit)
- {
- $words = explode(" ", $text, $limit+1);
- if (count($words) == $limit+1) {
- $words[$limit] = '...';
- }
- return implode(" ", $words);
- }
- }