Re: Matching Number of Times a Word Occurs...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Russell P Jones wrote:
Im trying to count the number of times a word occurs in a string - is the
only way to do this preg_match_all?

Russ Jones


No, there are hundreds of other ways; but, preg_match_all() is probably the easiest.

$number= preg_match_all("%$word%sm", $string, $matches);

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux