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:

$count = substr_count(' '.strtolower($string), strtolower(' '.$srch));
echo $count;

this won't help if there are newlines and other white space instead of
spaces, and won't help (so far) for a different set of circumstances...

it would be nice to extend substr_count() could be extended to have an


on 28/09/02 3:41 PM, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote:

> 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
> $srch="AVAILABLE";
> $count=substr_count(strtolower($string), strtolower($srch));
> echo $count;
> it puts the count a 2 even when one of the words is UNAVAILABLE
> how can I make it only count AVAILABLE and not UNAVAILABLE or visa
> verse

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to