public function test_wordLimiter() { $str = "This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test"; $result = wordLimiter($str, 10); $expected = 'This is a test This is a test This is...'; $this->assertEquals($expected, $result); }
?> <?php foreach ($packs as $pack) { ?> <tr> <td class="pack-img"><?php echo $pack->imgIsExists() ? CHtml::image($pack->getImgUrl()) : ''; ?> </td> <td class="desc"> <?php echo e($pack->title); ?> <br> <?php echo wordLimiter($pack->description, 20); ?> </td> <td><?php echo $pack->countItems; ?> </td> <td><span class="label <?php echo $pack->isStatusOn() ? 'label-success' : 'label-default'; ?> "><?php echo $pack->getStatus(); ?> </span></td> <td><?php echo $pack->sort;
/** * Возвращает небольшую часть сообщения * * @param int $count_word (кол-во слов которые надо вернуть) * * @return string */ public function getShortMessage($count_word = 10) { return wordLimiter(e(strip_tags($this->message)), $count_word, ' ...'); }