Page 1 of 1

getting the first 25 words of a paragraph

Posted: Sun Feb 18, 2007 11:32 pm
by psychotomus
how can I get the first 25 words of a paragraph? I know i could use explod(string, " ") then run a for loop to combine the first 25, but theres probally a much simplier way.

Posted: Sun Feb 18, 2007 11:43 pm
by dude81
The str-word-count could be of help :idea:.

Posted: Mon Feb 19, 2007 12:19 am
by Kieran Huggins
or maybe a regular expression?

Code: Select all

^(\w+[\.,-?/{[}\]<>=_`~]?\w*\s){1,25}

Posted: Mon Feb 19, 2007 12:54 am
by visitor-Q
have a look at strlen(), strpos(), and stristr(). you could also gain a little perspective from list() and each().

Posted: Mon Feb 19, 2007 1:53 am
by RobertGonzalez