Make an HTML Correct Teaser


/ Published in: HTML



Copy this code and paste it in your HTML
  1. // makeTeaser: makes a teaser for the number of words specified
  2. function makeTeaser($text, $numWords) {
  3. $words = split(' ', $text);
  4. $words = array_chunk($words, $numWords);
  5. $output = implode(' ', $words[0]);
  6. $output = strip_tags($output) . '...';
  7.  
  8. return $output;
  9. }
  10.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.