True, but it answers the original question. :) You can easily throw in a if($word == ' ') then don't save it, but still increment $pos. You could use a regular expression to check/remove punctuation, too.
---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ > -----Original Message----- > From: Marco Tabini [mailto:[EMAIL PROTECTED]] > Sent: Monday, December 16, 2002 12:37 PM > To: [EMAIL PROTECTED] > Cc: 'Uros Gruber'; PHP-General > Subject: RE: [PHP] Divide into words > > John, > > I'm not sure this will work if there is more than one space between > words. > > Also, my previous example won't work if there are duplicate words > (although it's easy to make an array out of each word and solve the > problem), nor if the words are delimited by any character other than > spaces, in which case regex are probably our best bet. > > Cheers, > > > Marco > -- > ------------ > php|architect - The magazine for PHP Professionals > The monthly worldwide magazine dedicated to PHP programmers > > Come visit us at http://www.phparch.com! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php