Posted By

breakerjump on 02/20/11


Tagged

php function limit word


Versions (?)

Word Limiter


 / Published in: PHP
 

URL: http://snipplr.com/view/43800/modified-word-limit-function/

  1. function limit_words($string, $word_limit)
  2. {
  3. $append = '';
  4. $words = explode(" ",$string);
  5. if(count($words) > $word_limit) {
  6. $append = '…';
  7. }
  8. return implode(" ",array_splice($words,0,$word_limit)) . $append;
  9. }

Report this snippet  

You need to login to post a comment.