RE: [PHP] Splitting at word count

From: Date: Fri, 26 Jan 2001 07:02:53 +0000
Subject: RE: [PHP] Splitting at word count
Groups: php.general 
Request: Send a blank email to php-general+get-36803@lists.php.net to get a copy of this message
> I'm doing a page where the front page will show "news" > stories. What I'd > like is if the story is longer than X words/chars/etc, the > index page will > show the first X words, then a link for the full story. > > Does anyone have a good idea on how to split after a certain number of > words? > > Thanks, > Wade Put the story in an array and grab the first x elements? Say you want 50 words you would do: $num_of_words = 50; $story_array = explode(" ", $story, $num_of_words); $story_preview = implode(" ", array_pop($story)); Assuming all words are seperated by a space. Dustin

« previous php.general (#36803) next »