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));
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
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_
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
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
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
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";
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
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
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
> 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
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
12 matches
Mail list logo