I have a news table which contains news stories. I'm wondering if it is possible to set a number of characters and have the script shorten the string from the database to the nearest word to the number of characters, and add a "... Read Full Story" link. My Title is in a seperate MySQL column from the body of the story.
I know it's possible to select x number of characters from the beginning of the string, but I don't know if it's possible to select to the nearest word (so it doesn't cut off a word), all assistance is appreciated... I've put an example below.
BEFORE SCRIPT:
Robot Race Ends Without Winner
(Washington Post) - The Pentagon-sponsored robot race held in Southern California today ended without a winner, as none of the autonomous vehicles built by the 15 qualifying teams was able to travel farther than 7 miles from the starting line. The odds-on favorite to win the race blew an engine after it traveled just seven miles from the starting line. Most of the other vehicles competing for a $1 million prize in the Pentagon's "Grand Challenge" failed to travel more than a few hundred yards from the starting point near Barstow, Calif.
AFTER SCRIPT:
Robot Race Ends Without Winner
(Washington Post) - The Pentagon-sponsored robot race held in Southern California today ended without a winner, as none of the autonomous vehicles built by the 15 qualifying teams was able to travel... <a href="#">Read Full Story</a>