I’m working on a site that pulls various public RSS feeds down. I want to show a HTMLless, short description of the feed entry.
Some of the feeds come with a nice excerpt but lots don’t so I’m left making my own from the full-content.
So what is the best/quickest/easiest way to take a block of text and slice it down to just the first couple of lines?
This function will reduce a block of text to a given word limit, so it wont cut if off part way through a word:
Example usage:
Outputs: