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

[PHP] counting words.

2003-04-06 Thread Sebastian
hello, I am trying to count the words from text that is fetched from mysql, It works, but it's a little inaccurate.. It's about 5 - 10 words off, My guess it's probably counting some HTML or something. Is there a more accurate way of counting words? $row[12] = strip_tags(strtr($row[12], array_

Re: Re[2]: [PHP] counting words in a string

2002-09-28 Thread olinux
wouldn't it be easier and more efficient to simply count the number of spaces in the string (and add 1)? using substr_count or something similar olinux --- Justin French <[EMAIL PROTECTED]> wrote: > You need to look at a few options... one is regular > expression (not my > forte), or perhaps w

Re: Re[2]: [PHP] counting words in a string

2002-09-28 Thread debbie_dyer
rray functions to do whatever else you need to do - counting, positions, etc Debbie - Original Message - From: "Justin French" <[EMAIL PROTECTED]> To: "Richard Kurth" <[EMAIL PROTECTED]>; "php-general" <[EMAIL PROTECTED]> Sent: Saturday, Sept

Re: Re[2]: [PHP] counting words in a string

2002-09-28 Thread Justin French
You need to look at a few options... one is regular expression (not my forte), or perhaps winding through the string one character at a time, writing a very simple state engine. Justin French on 28/09/02 4:47 PM, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > Hello Justin, > > That worked per

Re[2]: [PHP] counting words in a string

2002-09-27 Thread rdkurth
Hello Justin, That worked perfect but I have one more problem I need to know if one of the word is UNAVAILABLE I need to know if it is the first one or the second one. I don't know if there is any way to do this. 1st 2nd $string ="UNAVAILABLE AVAILABLE More Info";

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

[PHP] counting words in a string

2002-09-27 Thread rdkurth
I need to count how many times the word AVAILABLE appears in a string like this $string ="AVAILABLE More Info AVAILABLE More Info"; some time the string looks like this $string ="UNAVAILABLE More Info AVAILABLE More Info"; or $string ="AVAILABLE More Info UNAVAILABLE More Info"; when I use $src

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

[PHP] Counting Words In a String

2001-04-22 Thread Jason Beebe
Hi, 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 optimized way to