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. Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.