Hi all,
Is there a string function that will allow me to only display lets say the first 20 words from an article?
I have had a look through the manual but since I am not familiar with most functions it is like looking for a needle in a haystack.
Cheers
[SOLVED] Display only first 20 words from article.
Moderator: General Moderators
[SOLVED] Display only first 20 words from article.
Last edited by hairyjim on Mon Jun 21, 2004 10:32 am, edited 1 time in total.
Code: Select all
$howmany = 20;
$words = join(' ', array_slice(explode(' ', $article), 0, $howmany));- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
something like:
Code: Select all
preg_match('#^(\b[^\b]+\b){20}#',$article,$matches);
echo $matches[0];