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.
Autotrim article body text
1 reply to this topic
Posted 27 April 2006 - 10:49 AM
[!--coloro:#660000--][span style="color:#660000"][!--/coloro--]The Gene Pool Could Use A Little Chlorine[!--colorc--][/span][!--/colorc--]
Posted 27 April 2006 - 11:41 AM
Heres how I did it, I dont know how efficent it is but hey, it works.
$string = "here is a string that has a few words in it and is fairly long and boring and needs to be trimmed down so that it doesnt keep going and going and going and going"; $a = explode(" ",$string,21); array_pop($a); $output = implode(" ",$a); echo $output;
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users