Re: [PHP] counting words.

2003-04-06 Thread Jome
Justin French wrote: > It depends on what you define as a word, but let's take the simple > approach of stripping HTML et al, and exploding the string on the > spaces, then counting the array of words: > > $str = "This is my text that I want to count"; > $words = explode(' ', strip_tags($str));

Re: [PHP] counting words.

2003-04-06 Thread Justin French
It depends on what you define as a word, but let's take the simple approach of stripping HTML et al, and exploding the string on the spaces, then counting the array of words: text that I want to count"; $words = explode(' ', strip_tags($str)); $count = count($words); ?> Really no need for regex

Re: [PHP] counting words in a string

2002-09-27 Thread Justin French
if this is your SPECIFIC problem, putting a space at the beginning of $srch will help, eliminating XAVAILABLE... but this will cause a problem with the word AVAILABLE appearing at the start of the string, so temporarily put a space at the start of the string: this won't help if there are newlin

Re: [PHP] Counting Words In a String

2001-04-23 Thread Robert Vetter
Greg Donald wrote: > > > I want to check a string and return the amount of words present > > in it. These > > strings could be quite large, some higher than 100,000 > > characters. I realize > > I could explode the string on the whitespace and count the number > > of values. > > However, I'm no

RE: [PHP] Counting Words In a String

2001-04-22 Thread Greg Donald
> I want to check a string and return the amount of words present > in it. These > strings could be quite large, some higher than 100,000 > characters. I realize > I could explode the string on the whitespace and count the number > of values. > However, I'm not sure this would be the most opti