How to count how many times a certain word is used ,using php?

01 <?php
02 $count = 0; // count start form zero
03 $string = "bugphp -free online tutorials bugphp.com bugphp bugphp.com bugphpbugphp bugphp";
04
05 foreach( str_word_count($string ,1) as $a ) {
06 if( strtolower($a) == strtolower('bugphp') )  {
07 $count++;
08 }
09 }
10 echo "$count";
11 ?>
Advertisements

One thought on “How to count how many times a certain word is used ,using php?

  1. Pingback: PHP « amithmehta

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s