Posted By

cessnajumpin on 01/12/10


Tagged

php String excerpt


Versions (?)

Excerpt with Tag Stripping


 / Published in: PHP
 

Create an excerpt from the main copy, removing any image or other HTML tag markup so it will be clean. In this case the length is 160 characters, change that number to change the length of the excerpt

  1. public function makeNewsExcerpt($content)
  2. {
  3. $content = preg_replace("(\<(/?[^\>]+)\>)", "", $content);
  4. $content = substr($content, 0, 160);
  5. $content .= "...";
  6. return $content;
  7.  
  8. }

Report this snippet  

You need to login to post a comment.