I guess over a lot of words, the average length will be the same. Are you sure you don't want to get a certain number of characters, then go backwards or forwards to the nearest space or punctuation mark?
Anyway, you could use regular expressions, I recommend perl compatible regular expressions (PCRE). If you want to play around with PCRE's I recommend
http://samuelfullman.com/team/php/tools/regular_expression_tester_p.php
(try using strings like this: /[a-zA-Z0-9]*\s/i ... in the text area, on a series of text.
Or, you can split the words into an array using the space as the split item.
Can you tell me more what you're wanting to do?
Sam