haydndup Posted April 27, 2006 Share Posted April 27, 2006 I have a news section on the website that I am currently designing. I was hoping someone could give some advice on writing a function that will take text and trim it down to about 20 words... Basically giving a summary on each news item. I would then have a link to view the full article.Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/8538-autotrim-article-body-text/ Share on other sites More sharing options...
KrisNz Posted April 27, 2006 Share Posted April 27, 2006 Heres how I did it, I dont know how efficent it is but hey, it works.[code]$string = "here is a string that has a few words in it and is fairly long and boring and needs to be trimmeddown so that it doesnt keep going and going and going and going";$a = explode(" ",$string,21);array_pop($a);$output = implode(" ",$a);echo $output; [/code] Link to comment https://forums.phpfreaks.com/topic/8538-autotrim-article-body-text/#findComment-31275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.