Re: Matching Number of Times a Word Occurs...
| From: | Al | Date: | Wed, 20 Apr 2005 00:25:42 +0000 |
| Subject: | Re: Matching Number of Times a Word Occurs... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-213439@lists.php.net to get a copy of this message | ||
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 JonesNo, there are hundreds of other ways; but, preg_match_all() is probably the easiest. $number= preg_match_all("%$word%sm", $string, $matches);