/lib/Haanga/Extension/Filter/Truncatewords.php
PHP | 13 lines | 12 code | 1 blank | 0 comment | 2 complexity | b726f084936531ccff773b4ef2963f2e MD5 | raw file
1<?php 2 3class Haanga_Extension_Filter_Truncatewords 4{ 5 static function main($text, $limit) 6 { 7 $words = explode(" ", $text, $limit+1); 8 if (count($words) == $limit+1) { 9 $words[$limit] = '...'; 10 } 11 return implode(" ", $words); 12 } 13}